|
-
October 10th, 2001, 01:51 PM
#1
File Access
How can you read a file that has records of varying record sizes. For example a student file that contains the student name and anywhere from 0 to 15 quiz scores:
Lester Leeroy,10,20,35,40
Adam West,10,40,70,80,50,70,80
-
October 10th, 2001, 04:19 PM
#2
Re: File Access
No problem. The following simple program will open Autoexec.bat file and read it one line at a time then print that line. Line length is irrevelant.
option Explicit
Dim strTemp as string
private Sub Command1_Click()
Open "C:\Autoexec.bat" for input as #1
Do Until EOF(1)
Line input #1, strTemp
print strTemp
Loop
Close #1
End Sub
John G
-
October 15th, 2001, 02:45 PM
#3
Re: File Access
Thank you for your reply. What I am looking for is not so much a way to read the entire record but how to read the quiz scores into an array. Not having used Visual Basic very much I am not sure how to proceed. I would nortmally use a For-Next loop but when You do not know how many quiz scores there are how can you set up an indeterminate loop to read them into the program. What would you consider to be your terminating condition?
-
October 15th, 2001, 02:54 PM
#4
Re: File Access
You can use Split function
Dim strInput As String
Dim aryInput() As String
Dim intElement As Integer
strInput = "information1,information2,information3,information4"
aryInput = Split(strInput,",")
For intElement = LBound(aryInput) To UBound(aryInput)
Msgbox aryInput(intElement)
Next
Iouri Boutchkine
[email protected]
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
|