|
-
Nov 29th, 2000, 08:33 AM
#1
Thread Starter
Lively Member
How can I put the text which is in a multiline textbox into a combobox.
Each line in the textbox must be a new item in the combobox.
-
Nov 29th, 2000, 08:41 AM
#2
_______
<?>
' Is this what you are after
' Need VB6 for this split
Code:
Private Sub Command1_Click()
Dim x As Variant
x = Text1
x = Split(x, vbCrLf)
For i = LBound(x) To UBound(x)
Combo1.AddItem x(i)
Next i
End Sub
Private Sub Form_Load()
Dim i
For i = 1 To 5
Text1 = Text1 & i & vbCrLf
Next i
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 29th, 2000, 08:43 AM
#3
Fanatic Member
Joe was too fast, as usual, but I'll post my code anyway.
Code:
Private Sub Command1_Click()
Dim strArray() As String
Dim x As Integer
strArray = Split(Text1.Text, vbCrLf)
For x = 0 To UBound(strArray)
Combo1.AddItem strArray(x)
Next x
End Sub
-
Nov 29th, 2000, 08:44 AM
#4
_______
<?>
Code:
' this one for VB5 -
Private Sub Command1_Click()
Dim x As Variant
x = Text1
x = Split2(x, vbCrLf)
For i = LBound(x) To UBound(x)
Combo1.AddItem x(i)
Next i
End Sub
Private Sub Form_Load()
Dim i
For i = 1 To 5
Text1 = Text1 & i & vbCrLf
Next i
End Sub
'split function for VB5 and under vb6 has the function
'posted originally by Aaron Young
Public Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant
Dim sParts() As String
Dim lParts As Long
Dim lPos As Long
lPos = InStr(sString, sSeparator)
While lPos
ReDim Preserve sParts(lParts)
sParts(lParts) = Left(sString, lPos - 1)
sString = Mid(sString, lPos + Len(sSeparator))
lPos = InStr(sString, sSeparator)
lParts = lParts + 1
Wend
If Len(sString) Then
ReDim Preserve sParts(lParts)
sParts(lParts) = sString
End If
Split2 = IIf(lParts, sParts, Array())
End Function
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|