|
-
Feb 16th, 2002, 06:05 AM
#1
Thread Starter
New Member
text files???
I was wondering if someone could tell me how to read a text file and put it into an array?? the text file is something like :
9
bill
8
bill
34
john
I need to read the file and then put the numbers in an array and the names into another.
I know its probably simple but Im not as smart as the average bear!!! Please help
-
Feb 16th, 2002, 06:37 AM
#2
-= B u g S l a y e r =-
reading file into array sample
VB Code:
Private Sub Command1_Click()
Dim sArr() As String
Dim i As Integer
Open "C:\TEST.TXT" For Input As #1
sArr = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For i = 0 To UBound(sArr())
Debug.Print sArr(i)
Next i
End Sub
-
Feb 17th, 2002, 08:24 AM
#3
Thread Starter
New Member
Thanx but I wanted to do it something like this
Dim name As String
Dim seat As String
Dim i As Integer
txtIndex = row & SeatNo
Open "A:seat.txt" For Input As #1
Do While Not EOF(1)
Input #1, seat
lstSeat.AddItem txtSeatNo
ReDim Preserve CustSeat(0 To 71)
txtSeatNo = seat
Input #1, name
lstName.AddItem txtName()
'CustName.AddItem
ReDim Preserve CustName(0 To 71)
txtName() = CustName(0, 71)
'i = i + 1
Loop
Close #1
The array needs to be in a module
-
Feb 17th, 2002, 09:05 AM
#4
Lively Member
just do what peet has done and then add the items to the lst controls after you've read the file. or into the arrays that you want to use and then onto the controls.
Have Fun ;-)
Maartin
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
if it ain't broke don't fix, rewrite it.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
|