split/join function
The Split Function returns an array containing a specified number of substrings.
The following code shows how to split strings
Dim TheString As String = "Hello World!"
Dim TheArray() As String = Split(TheString)
Dim a = TheArray(0)
Dim b = TheArray(1)
Data on a and b variables are Hello and World respectively.
The following code shows how to split strings with multiple delimiters in a row and filter out the empty strings.
Dim TheString As String = "me myself you "
Dim TheArray() As String = Split(TheString)
Dim NotEmpty As Integer = -1
For i As Integer = 0 To TheArray.Length - 1
If TheArray(i) "" Then
NotEmpty += 1
TheArray(NotEmpty) = TheArray(i)
End If
Next
ReDim Preserve TheArray(NotEmpty)
Dim a = TheArray(0)
Dim b = TheArray(1)
Dim c = TheArray(2)
Data on a,b and c variables are me, myself and you respectively.
Join Function returns a string joined from a number of substrings contained in an array.
Dim TheString() As String = {"me", "myself", "you"}
Dim JoinedList As String = Join(TheString, ", ")
The result is “me, myself, you”.