Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleInitialize a ComboBox using values from a TextBox
KeywordsListItem, list, ComboBox, TextBox, add
CategoriesControls
 
Use InStr to search the text for carriage returns. Copy the TextBox's lines into the ComboBox.
 
Private Sub Command1_Click()
Dim pos As Integer
Dim txt As String
Dim entry As String

    Combo1.Clear

    txt = Text1.Text
    Do While Len(txt) > 0
        pos = InStr(txt, vbCrLf)
        If pos > 0 Then
            entry = Left$(txt, pos - 1)
            txt = Mid$(txt, pos + 2)
        Else
            entry = txt
            txt = ""
        End If
        txt = Trim$(txt)
        If Len(txt) > 0 Then Combo1.AddItem entry
    Loop

    Text1.Text = ""
    Combo1.ListIndex = 0
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated