Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27059

Multiple Choice using Arrays and Booleans

$
0
0
I'm currently working on a Multiple choice quiz program.

I have my arrays:
Code:

Dim Symbols() As String = {"あ", "え", "い", "お", "う", "か", "け", "き", "こ", "く", "が", "げ", "ぎ", "ご", "ぐ"}
Dim Answers() As String = {"A", "E", "I", "O", "U", "KA", "KE", "KI", "KO", "KU", "GA", "GE", "GI", "GO", "GU"}

I also have my booleans:
Code:

Dim sym1 As Boolean = False
Dim sym2 As Boolean = False
Dim sym3 As Boolean = False
Dim sym4 As Boolean = False
Dim sym5 As Boolean = False
Dim sym6 As Boolean = False
Dim sym7 As Boolean = False
Dim sym8 As Boolean = False
Dim sym9 As Boolean = False
Dim sym10 As Boolean = False
Dim sym11 As Boolean = False
Dim sym12 As Boolean = False
Dim sym13 As Boolean = False
Dim sym14 As Boolean = False
Dim sym15 As Boolean = False

And then I have my random:
Code:

Dim MyRandom As New Random
When the form loads, it displays the following code:
Code:

TextBox1.Text = Symbols(MyRandom.Next(0, Symbols.Length))
optionOne.Text = Answers(MyRandom.Next(0, Answers.Length))
optionTwo.Text = Answers(MyRandom.Next(0, Answers.Length))
optionThree.Text = Answers(MyRandom.Next(0, Answers.Length))
optionFour.Text = Answers(MyRandom.Next(0, Answers.Length))

optionOne, optionTwo, optionThree, and optionFour are all radiobuttons. As you can see, with the current code, it randomly selects an index value from each Array and displays the text value.
The first part with Textbox1 is fine. Randomly generating an index from the Answers array isn't exactly what I want. I need the options listed to not repeat each other and I need to make sure
that one of the options HAS to be the correct answer. Each symbol must be used at least once and cannot repeat as well. I'm trying to create this program for a friend and I wasn't expecting
this to be as complicated for myself as I had thought.

Anyways, I'm really needing help. If I was unclear on anything, let me know. I can post my source code if needed, but I'm pretty sure that's most of it. Thanks for reading! :)

~S3R0

Viewing all articles
Browse latest Browse all 27059

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>