|
|
Title | Initialize a ComboBox using values from a TextBox |
Keywords | ListItem, list, ComboBox, TextBox, add |
Categories | Controls |
|
|
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
|
|
|
|
|
|