|
-
Nov 15th, 2001, 02:17 PM
#1
Thread Starter
New Member
how to put data from file into Array?
Hi!
I have a problem with putting data(UDT) from file into array. What I have is 15 Questions(+answers, question number, and correct answer) on the floppy disk. I used UDT(QType)
The array's name is Questions as QType
But I have trouble with putting the whole question(one by one) into that array, so that later I could randomize them.
I tried to use loop Do Until EOF for this, But I do not know what goes where.
My option explicit looks like this:
Option Explicit
Public Type QType
QN As Integer
Q As String * 200
A(4) As String * 100
CA As Integer
End Type
Public theQuestion As QType
Public questions(15) As QType
And in the form:
Dim QuestNum As Integer
Open "a:\test.txt" For Random Access Read Write As #11 Len = Len(theQuestion)
'open the file
Get #11, QuestNum, questions(15) 'Right here not sure?
'start at Qnum 1
lblStQuestNum.Caption = 1 'where the number of question apperars
QNum = lblStQuestNum.Caption
'do until eof
Do Until EOF(11)
questions (lblStQuestNum.Caption) 'This is the problem part!!!
QNum = QNum + 1
Loop
I would really appreciate if you help me!!!
Thank you very much!
Sincerely,Mariya
-
Nov 15th, 2001, 04:22 PM
#2
Frenzied Member
ok do this:
VB Code:
Open "a:\test.txt" For Random Access Read Write As #11 Len = Len(theQuestion)
lblStQuestNum.Caption = 1
QNum = lblStQuestNum.Caption
for I = 1 to 15
Get #11, QNum, questions(I)
next I
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
|