Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

ListBox DataSource?

I hope I'm not bothering anyone by asking a lot of questions with minimal contribution to the other threads, but I am learning as I make this program. I don't know how complex it will get but all I can do is take it one step at time :P

Heres my question: How do I popluate my "Members" listbox in the example below, using a text file? There will be more then one listbox needing the member list as you can see below. The purpose of this feature is to keep track of member's attendance and apply points each of their names which they use to purchase items in game from the Linkshell.

http://img.photobucket.com/albums/v121/egotave/Help1.png
[672 byte] By [NP209] at [2007-11-11 10:22:50]
# 1 Re: ListBox DataSource?
Dim hFile As Integer
Dim sText As String

hFile = FreeFile
Open "d:\path\file.txt" For Input As hFile
Do Until EOF(hFile)
Line Input #hFile, sText
lstMembers.AddItem sText
Loop
Close hFile
Phil Weber at 2007-11-11 17:22:46 >
# 2 Re: ListBox DataSource?
Hmm I don't think I understand this Part fully. Here is what I have tried to do, with the code you gave me. I'm sure I have left something out or not changed the right variables. The Name of the text file i wanna use is "Memberlist.txt"

Dim hFile As Integer
Dim sText As String

hFile = FreeFile
Open "C:\Documents and Settings\NP209\Desktop\Linkshell Plus\Memberlist.txt" For Input As hFile
Do Until EOF(hFile)
Line Input #hFile, sText
lstMembers.AddItem sText
Loop
Close hFile
NP209 at 2007-11-11 17:23:46 >
# 3 Re: ListBox DataSource?
What is the structure of your Memberlist.txt file? Is each item on a separate line?
pclement at 2007-11-11 17:24:44 >
# 4 Re: ListBox DataSource?
Also, is your listbox named lstMembers?
Phil Weber at 2007-11-11 17:25:50 >
# 5 Re: ListBox DataSource?
http://img.photobucket.com/albums/v121/egotave/Help2.png

Yes my lisbox's are named lstMembers, and my text file is structured as a 1 name per line setup.
NP209 at 2007-11-11 17:26:49 >
# 6 Re: ListBox DataSource?
How does my code "not work?" What happens when you run it?
Phil Weber at 2007-11-11 17:27:50 >
# 7 Re: ListBox DataSource?
I apologize i see what i did wrong. I had changed my real name in the "Open path" line to my Screen name on here since i didn't want to release my real name. I forgot to change that back. Now that i have edited that back it works now. thanks guys your awesome ^^
NP209 at 2007-11-11 17:28:54 >