-
-
Notifications
You must be signed in to change notification settings - Fork 18
Split method
Xusinboy Bekchanov edited this page Oct 30, 2023
·
3 revisions
Returns a zero-based, one-dimensional array containing a specified number of substrings.
Split(expression, delimiter, result, [ matchcase ]]])
The Split function syntax has these named arguments:
Part | Description |
---|---|
expression | Required. String expression containing substrings and delimiters. If expression is a zero-length string(""), Split returns an empty array, that is, an array with no elements and no data. |
delimiter | String character used to identify substring limits. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned. |
result | Variable where the result is returned. |
matchcase | Optional. Boolean value indicating the kind of comparison to use when evaluating substrings. |
This example shows how to use the Split method.
#include "mff/UString.bi"
Dim strFull As String
Dim arrSplitStrings1() As String
Dim arrSplitStrings2() As String
Dim strSingleString1 As String
Dim strSingleString2 As String
Dim i As Long
strFull = "Dow - Fonseca - Graham - Kopke - Noval - Offley - Sandeman - Taylor - Warre" ' String that will be used.
Split(strFull, "-", arrSplitStrings1()) ' arrSplitStrings1 will be an array from 0 To 8.
' arrSplitStrings1(0) = "Dow " and arrSplitStrings1(1) = " Fonesca ".
' The delimiter did not include spaces, so the spaces in strFull will be included in the returned array values.
Split(strFull, " - ", arrSplitStrings2()) ' arrSplitStrings2 will be an array from 0 To 8.
' arrSplitStrings2(0) = "Dow" and arrSplitStrings2(1) = "Fonesca".
' The delimiter includes the spaces, so the spaces will not be included in the returned array values.
'Multiple examples of how to return the value "Kopke" (array position 3).
strSingleString1 = arrSplitStrings2(3) ' strSingleString1 = "Kopke".
For i = LBound(arrSplitStrings2, 1) To UBound(arrSplitStrings2, 1)
If InStr(1, arrSplitStrings2(i), "Kopke") > 0 Then
strSingleString2 = arrSplitStrings2(i)
Print strSingleString2
Exit For
End If
Next i
Sleep
- Table of Contents
- Controls and objects
- Controls
- Animate
- Chart
- CheckBox
- CheckedListBox
- ComboBoxEdit
- ComboBoxEx
- CommandButton
- DateTimePicker
- Grid
- Header
- HotKey
- HScrollBar
- ImageBox
- IPAddress
- Label
- LinkLabel
- ListControl
- ListView
- MonthCalendar
- PageScroller
- ProgressBar
- RadioButton
- ReBar
- RichTextBox
- ScrollBarControl
- Splitter
- StatusBar
- TextBox
- ToolBar
- ToolPalette
- TrackBar
- TreeListView
- TreeView
- UpDown
- VScrollBar
- WebBrowser
- Containers
- Components
- Dialogs
- Controls
- Functions and methods
- Numeric functions
- String functions
- Pointer functions