parse-string

 

Parse String Using A Specific Delimiter


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
Dim iCounter As Integer
Dim 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)
Next

End Sub