|
|
Title | Split a multiline string into pieces in VB 6 |
Description | This example shows how to split a multiline string into pieces in Visual Basic 6. It uses the Split function to brak the string into pieces separated by vbCrLf. |
Keywords | split, multi-line, multiline, parse |
Categories | Strings |
|
|
Thanks to Darren Jones.
The program uses the Split function (VB 6 and later) to break the string into pieces. It splits at the vbCrLf line delimiters. It loops through the results and places each string in a ListBox.
|
|
Private Sub Command1_Click()
Dim pos As Integer
Dim entry() As String
entry = Split(Text1.Text, vbCrLf, , vbTextCompare)
pos = 0
Do While pos < UBound(entry)
If Trim$(entry(pos)) <> "" Then
Combo1.AddItem entry(pos)
End If
pos = pos + 1
Loop
Text1.Text = ""
If Combo1.ListCount = 0 Then
Combo1.ListIndex = -1
Else
Combo1.ListIndex = 0
End If
End Sub
|
|
|
|
|
|