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.
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
Function For Each in Array
Dim arrKata() as string
Dim arrX as Variant ' Harus Variant
For Each arrX In arrKata
MsgBox arrX ' Menampilkan seluruh variabel array
Next
Tidak ada komentar:
Posting Komentar