vb.net - How to read From Text Files line by line - multiple choice Quiz -


hi need this, need make multiple choice question program reads questions , answers 2 different text files (notepad files) when try cant seem working. have tried loops didn't work tried arrays didn't meet requirements of reading form text file

so come need reading text file line tine , updating when new question needs given

i cannot 1 read line line (questions.txt) , need have match question in answers.txt need update when next question clicked

vb.net

program need create must following

  • questions , answers should loaded file called questions.txt , answers.txt respectively

-questions should appear in random order, every time program executed

-update form next question

-keep track on how many questions correct

any resources or tutorials on of above muchly appreciated

total edits: 198305769 lol. cleaned answer, , should complete. cheers.

declare global variable (integer); that's you'll assign amount of questions user has answered:

public class form1   dim keepscore integer = 0 

not neatest, appends each line selected text file array , can iterate through it.

   dim ofd new openfiledialog     ofd.showdialog()     dim xstr = ofd.filename      dim questions() string = io.file.readalllines(ofd.filename)     dim answers() string = io.file.readalllines(ofd.filename)      dim sw new stringbuilder      dim integer = 0     until = questions.count()         sw.appendline(trim(questions(i)))            msgbox(questions(i)) 'only added can see lines         = + 1     loop     until = answers.count()         sw.appendline(trim(answers(i)))            msgbox(answers(i)) 'only added can see lines         = + 1     loop 

add onto end of function if statement:

if correctanswer.checked = true 'assuming using radiobutton group, or checkbox    keepscore = keepscore + 1 end if 

here quick number randomiser, assuming have 20 questions (change 20 accordingly whatever amount of questions have):

    randomize()     dim integer = cint(int(20 * rnd() + 1))     msgbox(i) 

best of luck.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -