Results 1 to 6 of 6

Thread: sequential file reading ...

  1. #1

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    ok i have to admit that i thought what i wanted to do would be simpler that it turned out to be

    my friend asked me to make him a program that would read his questions from a text file and answers too ... also he wants his questions to be randomize ...

    i've thought of the following to make it simpler:

    let him make 2 text files named whatever he wants ... i'll be able to open it from a dialog box ...

    make each question start with a # and make each question fit in a line and not go to the next

    having those things set already is a good idea to make it less complex right?

    well now the following is how its supposed to work in code but i have no idea how to do it ...

    text file 1 named questions:
    1 question
    2 question
    3 question
    4 question
    5 (n so on cause he can put as much as he wants)

    text file 2 named answers:

    1 answer
    2 answer
    3 answer
    4 answer
    5 (and so on)

    now how would i go about randomizing them?

    so on a textbox in my form a question will come up:
    3 question

    and in another textbox have the answer come out:
    3 answer

    this was harder to do than i thought ... please help

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Posts
    125
    Option Explicit

    Private Type QandA
    Question As String
    Answer As String
    End Type

    Dim QA(100) As QandA
    Dim lastQ As Integer

    Private Sub Form_Load()
    Dim q%, a%

    q = FreeFile
    Open "Questions" For Input As q
    a = FreeFile
    Open "Answers" For Input As a

    Do Until EOF(q)
    lastQ = lastQ + 1
    Line Input #q, QA(lastQ).Question
    Line Input #a, QA(lastQ).Answer
    Loop
    Close
    End Sub


    you can then do your rnd on a number between 1 and lastQ

  3. #3
    Guest
    It would be much easier (in my opinion) to have both question and answer in the same file (on the same line), and seperate them with an uncommon character (ie a character that will not occur in the questions or answers)

    than all you'd have to do is load the file into a two-dimensional array and away you go!

  4. #4

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    2 dimensional???

    makai ... i haven't learn data types and i really don't want to code something i don't know ...

    can anyone help me out ???

    [Edited by theman32x on 12-17-2000 at 11:08 PM]

  5. #5

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305

    please don't let my post die

    please help

  6. #6

    Thread Starter
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    no one can help ???

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