|
|
Title | Copy multi-line text into a ListBox |
Keywords | ListBox, copy, additem, text, TextBox |
Categories | Controls |
|
|
Use InStr to find the vbCrLf characters. Use Left$ and Mid$ to break the
text apart and add the lines to the ListBox.
|
|
Private Sub Command1_Click()
Dim txt As String
Dim pos As Integer
List1.Clear
txt = Text1.Text
Do While Len(txt) > 0
pos = InStr(txt, vbCrLf)
If pos = 0 Then
List1.AddItem txt
txt = ""
Else
List1.AddItem Left$(txt, pos - 1)
txt = Mid$(txt, pos + Len(vbCrLf))
End If
Loop
End Sub
|
|
Formatted by
Neil Crosby
|
|
|
|
|
|