Jumat, 24 September 2010

Textbox to Listbox - VB6


To Make Textbox to Listbox and Listbox to Textbox follow this step :
1. Create 1 Form (Form1)
2. Create 1 Textbox (Text1.text)
3. Create 1 Listbox (List.List)
4. Create 2 CommandButton (Command1 and Command2)
Paste Code Bellow to Form 1 :
Private Sub Command1_Click()
Dim strParts() As String
Dim lngIndex As Long

strParts = Split(Text1.Text, vbCrLf)
For lngIndex = 0 To UBound(strParts)List1.AddItem strParts(lngIndex)
Next
Text1.Text = ""
End Sub

Private Sub Command2_Click()
Dim i As Integer
Dim linedata As String
For i = 0 To List1.ListCount - 1
If (List1.ListCount - 1) - i = 0 Then
Text1.Text = Text1.Text & List1.List((List1.ListCount - 1) - i)
Else
Text1.Text = Text1.Text & List1.List((List1.ListCount - 1) - i) & vbCrLf
End If
Next
List1.Clear
End Sub

Related Post :



0 comments:

R