|
-
Dec 16th, 2000, 10:14 PM
#1
Thread Starter
Hyperactive Member
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
-
Dec 17th, 2000, 12:16 AM
#2
Lively Member
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
-
Dec 17th, 2000, 06:41 AM
#3
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!
-
Dec 17th, 2000, 10:12 AM
#4
Thread Starter
Hyperactive Member
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]
-
Dec 17th, 2000, 11:11 PM
#5
Thread Starter
Hyperactive Member
please don't let my post die
-
Dec 18th, 2000, 05:22 PM
#6
Thread Starter
Hyperactive Member
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
|