|
-
Jan 24th, 2010, 02:32 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Populate a Listbox
i have figured it out how to fill a listbox with a textfile
but cant do the rest do have to split the string add them to the list index
For i = 1 To UBound(split)
my text file is like this
one
......... blue
......... red
tow
......... green
......... yellow
i have 2 list box i want to load the string one and tow into list1
and when a user click on a list1 item one fill the list2 index with
blue
red
and so on
thanks
Private Sub Form_Load()
Dim txtstring As String
Open App.Path & "\pictuer.text" For Input As #1
list1.Clear
While Not EOF(1)
Input #1, txtstring
list1.AddItem txtstring
Wend
Close #1
End Sub
text file
.............................
one
......... blue
......... red
tow
......... green
......... yellow
Last edited by bordino; Jan 24th, 2010 at 03:24 AM.
-
Jan 24th, 2010, 03:20 AM
#2
Thread Starter
Addicted Member
Re: Populate a Listbox
cant make it work i dont know what im doing wrong here
Dim LoadData
Dim pic
Dim num
Private Sub List1_Click()
List2.Clear
num = Split(pic(List1.Index + 1), "*")
For i = 1 To UBound(num)
List2.AddItem (i)
Next i
End Sub
Private Sub Form_Load()
LoadTxtFile
End Sub
Public Sub LoadTxtFile()
On Error GoTo dlgerror
Dim sCurrent As String
LoadData = ""
Open App.Path & "\pictuer.txt" For Input As #1
Do Until EOF(1)
Line Input #1, sCurrent
LoadData = LoadData & sCurrent
Loop
Close #1
pic = Split(LoadData, "@")
For i = 1 To UBound(pic)
List1.AddItem (i)
Next i
dlgerror:
Exit Sub
End Sub
my text file
.......................................
@one*
blue*
red*
@tow*
green*
yellow *
Last edited by bordino; Jan 24th, 2010 at 03:23 AM.
-
Jan 24th, 2010, 03:24 AM
#3
Lively Member
Re: Populate a Listbox
 Originally Posted by bordino
i have figured it out how to fill a listbox with a textfile
but cant do the rest do have to split the string add them to the list index
For i = 1 To UBound(split)
my text file is like this
one
......... blue
......... red
tow
......... green
......... yellow
i have 2 list box i want to load the string one and tow into list1
and when a user click on a list1 item one fill the list2 index with
blue
red
and so on
thanks
Private Sub Form_Load()
Dim txtstring As String
Open App.Path & "\chapter.text" For Input As #1
list1.Clear
While Not EOF(1)
Input #1, txtstring
list1.AddItem txtstring
Wend
Close #1
End Sub
text file
.............................
one
......... blue
......... red
tow
......... green
......... yellow

im currently working on it heres the code what i have come upto till now
Code:
Private Sub Form_Load()
Dim txtstring, filt As String
Open "c:\chapter.txt" For Input As #1
List1.Clear
Do Until EOF(1)
Input #1, txtstring
filt = Left(txtstring, 1)
If filt <> "." Then
List1.AddItem txtstring
End If
Loop
Close #1
End Sub
Private Sub List1_Click()
Dim a, btxtstring, filt As String
Open "c:\chapter.txt" For Input As #1
List2.Clear
Do Until EOF(1)
Input #1, txtstring
filt = Left(txtstring, 1)
If filt = "." Then
List2.AddItem txtstring
End If
Loop
Close #1
End Sub

Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.
-
Jan 24th, 2010, 03:49 AM
#4
Thread Starter
Addicted Member
-
Jan 24th, 2010, 05:25 AM
#5
Re: Populate a Listbox
 Originally Posted by bordino
thanks man
If your problem is solved, please MARK thread using
Thread Tools menu link, then click to Mark Thread Resolved link
-
Jan 24th, 2010, 12:39 PM
#6
Thread Starter
Addicted Member
-
Jan 24th, 2010, 07:31 PM
#7
Re: [RESOLVED] Populate a Listbox
 Originally Posted by bordino
here was the problem with my code
List1.ListIndex
What mean?
List1.ListIndex isn't a problem, it's a property.
What is the problem?
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
|