News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Split a multiline string into pieces

Started by nandagopal, Nov 06, 2008, 07:17 PM

Previous topic - Next topic

nandagopal

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