Results 1 to 2 of 2

Thread: how to put data from file into Array?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    WA
    Posts
    4

    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

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    ok do this:

    VB Code:
    1. Open "a:\test.txt" For Random Access Read Write As #11 Len = Len(theQuestion)
    2.  
    3. lblStQuestNum.Caption = 1
    4.  
    5. QNum = lblStQuestNum.Caption
    6.  
    7. for I = 1 to 15
    8.   Get #11, QNum, questions(I)
    9. next I
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width