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
 
 
 
 
 
 
TitleSplit a multiline string into pieces in VB 6
DescriptionThis 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.
Keywordssplit, multi-line, multiline, parse
CategoriesStrings
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated