Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleCopy multi-line text into a ListBox
KeywordsListBox, copy, additem, text, TextBox
CategoriesControls
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated