May 12th, 2005, 07:04 PM
|
#1 (permalink)
| | The Macedonian Member
Join Date: Mar 2004 Location: Macedonia Point, IN
Posts: 3,363
|
I need some Visual Basic help. I cant think of the code something I need for my program. When I press "Get Roster" I need it to pull all the info from a Text File and the place all the info into a Listbox, I cant think of the code Blaise helped me last night but i forgot to save the code and I lost It so I need your guys help.
TIA |
| |
May 12th, 2005, 07:40 PM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,026
| |
| |
May 12th, 2005, 07:49 PM
|
#3 (permalink)
| | The Macedonian Member
Join Date: Mar 2004 Location: Macedonia Point, IN
Posts: 3,363
|
well Input as #1 but i want it to go into a Listbox |
| |
May 12th, 2005, 07:51 PM
|
#4 (permalink)
| | I am a banana!
Join Date: Jun 2002 Location: Texas Tech
Posts: 3,921
|
there is a 'listboxname.additem("item name")' command you can use in conjunction with Input as #1 |
| |
May 12th, 2005, 08:03 PM
|
#5 (permalink)
| | The Macedonian Member
Join Date: Mar 2004 Location: Macedonia Point, IN
Posts: 3,363
| Quote: |
Originally Posted by originel there is a 'listboxname.additem("item name")' command you can use in conjunction with Input as #1 |
See how do i do that? I need it to add to the list |
| |
May 12th, 2005, 08:18 PM
|
#6 (permalink)
| | I am a banana!
Join Date: Jun 2002 Location: Texas Tech
Posts: 3,921
|
here's an example: Code: dim myArray[arraysize]
'Code that will get the info from the file using the above methods
'i don't know how to do it off the top of my head and am too lazy to read up on it
for i = 0 to arraysize - 1
listboxname.AddItem(myArray[i])
loop Simple as that
(btw...better check syntax...i've been coding in C++ for the last two weeks and so I'm probably mixing the two syntax's). |
| |
May 13th, 2005, 12:16 AM
|
#7 (permalink)
| | Ultimate Member
Join Date: Oct 2001
Posts: 21,026
|
I rarely use input as #1 not much control over it Code: Dim objFSO As FileSystemObject
Dim oInputFile as File
Set objFSO = New FileSystemObject
Set objFile = objFSO.OpenTextFile("C:\Somefile.txt", FOR_READING)
Do While Not objInputFile.AtEndOfStream
sCurLine = Trim(objInputFile.ReadLine)
If sCurLine <> "" Then
lstBox.AddItem sCurLine
End If
Loop
objInputFile.Close
Set objInputFile = Nothing
Set objFSO = Nothing something like that, but make sure to add Scripting Runtime as a reference to get the FSO available. |
| |
May 13th, 2005, 12:19 AM
|
#8 (permalink)
| | The Macedonian Member
Join Date: Mar 2004 Location: Macedonia Point, IN
Posts: 3,363
| Quote: |
Originally Posted by vass0922 I rarely use input as #1 not much control over it Code: Dim objFSO As FileSystemObject
Dim oInputFile as File
Set objFSO = New FileSystemObject
Set objFile = objFSO.OpenTextFile("C:\Somefile.txt", FOR_READING)
Do While Not objInputFile.AtEndOfStream
sCurLine = Trim(objInputFile.ReadLine)
If sCurLine <> "" Then
lstBox.AddItem sCurLine
End If
Loop
objInputFile.Close
Set objInputFile = Nothing
Set objFSO = Nothing something like that, but make sure to add Scripting Runtime as a reference to get the FSO available. |
See that looks like something ifce dones but never used al that stuff, Lets just say i havent learned anything in that Class |
| |
May 13th, 2005, 12:29 AM
|
#9 (permalink)
| | Member
Join Date: Apr 2005
Posts: 111
|
I pull off a lazy method where I load the file into a rich text box, use a bunch of loops to search for certain text, and then I do what I want with it. quite neat really
__________________
AMD Athlon 64 4000+ @ 2.6 GHz
MSI nForce4 SLI S939 @ 2000MHz FSB
OCZ 2GB PC3200 DDR RAM
BFG 256MB GeForce 7800GTX PCIe @ 460/1300
|
| |
May 13th, 2005, 12:29 AM
|
#10 (permalink)
| | The Macedonian Member
Join Date: Mar 2004 Location: Macedonia Point, IN
Posts: 3,363
|
Like I remember something Code: Open App.Path & "\Roster.txt" For Random As #1(I think)
Line Input as #1 or something like that I cant remember at all |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |