Parse String Using A Specific Delimiter

Author: Microsoft

You can split the string "Cats,Dogs,Horses,Birds" to the substrings "Cats", "Dogs", "Horses" and "Birds".
The code below use the function 'split' that available only in VB 6.0 and above.

Form Code

Private Sub Form_Load()
Dim strAnimals As String
iCounter As Integer
arrAnimals() As String

strAnimals = "Cats,Dogs,Horses,Birds"
'replace the "," below with your delimiter
arrAnimals = Split(strAnimals, ",")

For iCounter = LBound(arrAnimals) To UBound(arrAnimals)
MsgBox arrAnimals(iCounter)

End Sub

Go Back