How can limit how many times an operator shows up in my maths quiz in vb? - vb.net

My task was to create a 10 question maths quiz with 2 random numbers and a random operator (only +, - or *) for each question. Also the program must ask for the users name. Which I have done.
But as my quiz has only 10 questions, there is a very small probability that one of the operators will be in the majority or that one may not show up. So basically I need something that can limit how many times each operator shows up, for example each operator can only show up 4 times.
As you can see from my code, I'm coding in form. I would be very grateful if you could help me with this as I couldn't find anything on the internet for it and I'm also not too sure how to go about solving this problem either.
Private Sub StartTheQuiz()
number1 = randomizer.Next(1, 13)
number2 = randomizer.Next(1, number1)
leftpluslbl.Text = number1.ToString
rightpluslbl.Text = number2.ToString
userinput.Value = 0
Correct.Visible = False
Incorrect.Visible = False
End Sub
Public Sub TheOperator()
Randomize()
operation = randomizer.Next(1, 4)
addmintime = operation
If addmintime = 1 Then
answer = number1 + number2
operatorlbl.Text = "+"
Userinput.Value = useranswer
ElseIf addmintime = 2 Then
answer = number1 - number2
operatorlbl.Text = "-"
Userinput.Value = useranswer
ElseIf addmintime = 3 Then
answer = number1 * number2
operatorlbl.Text = "x"
Userinput.Value = useranswer
End If
End Sub
Public Function CheckTheAnswer()
If userinput.Value = answer Then
Return True
Else
Return False
End If
End Function
Private Sub Start_Click(sender As Object, e As EventArgs) Handles Start.Click
If NameBox.Text = "What is your name? Enter your name here" Then
NameBox.BackColor = Color.Red
NextBtn.Visible = False
Check.Visible = False
Else
StartTheQuiz()
NameBox.BackColor = Color.LimeGreen
Start.Enabled = False
Start.Visible = False
TheOperator()
question = 0
score = 0
Check.Visible = True
NameBox.Enabled = False
End If
End Sub
Private Sub Check_Click(sender As Object, e As EventArgs) Handles Check.Click
If CheckTheAnswer() = True Then
Correct.Visible = True
Incorrect.Visible = False
question = question + 1
score = score + 1
ElseIf CheckTheAnswer() = False Then
Correct.Visible = False
Incorrect.Visible = True
question = question + 1
score = score + 0
End If
NextBtn.Visible = True
Check.Visible = False
End Sub
Private Sub NextBtn_Click(sender As Object, e As EventArgs) Handles NextBtn.Click
If question < 10 Then
StartTheQuiz()
TheOperator()
Check.Visible = True
NextBtn.Visible = False
ElseIf question >= 10 Then
MessageBox.Show("You have scored " & score & "/10")
MessageBox.Show("Goodbye")
Me.Close()
End If
End Sub
End Class

Here's an example of what I mentioned in the comments. It builds a list of the desired number of operations in equal quantities, then shows how to pull a random one from that list:
Public Class Form1
Private Operations As New List(Of String)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Operations = CreateOperations(10)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Operations.Count > 0 Then
Dim operation As String = NextRandomOperation()
Debug.Print(operation)
Else
Debug.Print("No more operations in list!")
End If
End Sub
Private Function CreateOperations(ByVal NumberOperations As Integer) As List(Of String)
Dim operators() As String = {"+", "-", "X"}
Dim operations As New List(Of String)
While Operations.Count < NumberOperations
Operations.AddRange(operators)
End While
While Operations.Count > NumberOperations
Operations.RemoveAt(Operations.Count - 1)
End While
Return operations
End Function
Private Function NextRandomOperation() As String
Static R As New Random
If Operations.Count > 0 Then
Dim index As Integer = R.Next(Operations.Count)
Dim operation As String = Operations(index)
Operations.RemoveAt(index)
Return operation
End If
Return ""
End Function
End Class

The proposed solution above will always produce four +, three - and three X. If you want a more random distribution you need to randomize the operators() array.
Dim rnd As New System.Random
Dim operators() As String = New String() {"+", "-", "X"}.OrderBy(Function() rnd.Next).ToArray

Related

How do I count how many guesses it takes to get the correct number in Visual Basic?

I have been struggling with this code for a while. I'm trying to make it so after the user gets the number right, the program counts how many tries it has taken them to get the number right. How can I do this?
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
'SELECTS THE SECTET NUMBER
Randomize() 'WITHOUT rANDOMIZE, THE SAME SEQUENCE OF NUMBERS APPEARS EACH RUN
secretNumber = Int(Rnd(1) * 1000 + 1) 'picks a random nubmer between 1 and 1000
'sets the initial prompts
Me.lblLow.Text = 1
Me.lblHigh.Text = 1000
Me.txtGuess.Focus()
Dim count As Integer
btnEnterGuess.Enabled = True
btnStart.Enabled = False
Dim i As Integer
For i = 1 To count
count = count + 1
Next i
Do
count = count + 1
Loop Until count = secretNumber
MessageBox.Show("It took you " & i - 1 & " tries to get the number correct.")
End Sub
I threw this piece of code togeather, hopefully it will help.
Something to note when writing this kinda code, is that all this code is running on a single thread (unless you declare it otherwise). This means your program will become unresponsive when you run that for loop.
Public Class Form1
Dim count As Integer = 0
Dim answer As Integer = 0
Dim GameRunning As Boolean = True
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message,
ByVal keyData As System.Windows.Forms.Keys) _
As Boolean
'Gets all keystrokes on the fourm
If GameRunning Then
'converts keystroke to key ID and tests to see if the keystroke is the ENTER key
If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
'try catch to prevent crash if text in entered
Try
If txtAnswer.Text = answer Then
MessageBox.Show("Congratz! It took you " & count & " tries to guess the number!")
Else
txtAnswer.Text = ""
count = (count + 1)
End If
Catch ex As Exception
End Try
End If
End If
'update label to show tries
lblTries.Text = "Tries: " & count
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
Private Sub SetupOnLoad() Handles MyBase.Load
Reset()
End Sub
Public Sub Reset()
count = 0
Randomize()
answer = Int(Rnd(1) * 1000 + 1)
txtAnswer.Text = ""
lblTries.Text = "Tries: " & count
GameRunning = True
End Sub
'the Reset() code is ran on the program launch and when you press the button to prepare the game.
Private Sub Reset_Game() Handles BtnReset.Click
Reset()
End Sub
End Class
This code gets the user input in the text box. When the user presses ENTER, the program tests to see if its the correct number.
Hope this helped!
I will try something like this, randomize need to be placed outside of the click
Public Class Form1
Dim count As Integer = 0
Dim answer As Integer = 0
Private Sub btnStart_ClicK(sender As Object, e As EventArgs) Handles btnStart.Click
Randomize()
answer = Int(Rnd(1) * 1000 + 1)
btnStart.Enabled = False
btnGuess.Enabled = True
End Sub
Private Sub btnGuess_Click(sender As Object, e As EventArgs) Handles btnGuess.Click
count += 1
If answer = TextBox1.Text Then
MessageBox.Show("It took you " & count & " tries to get the number correct.")
btnStart.Enabled = True
btnGuess.Enabled = False
count = 0
answer = 0
Else
TextBox1.Text = ""
End If
End Sub
End Class

How to randomize a quiz on vbnet

I'm new at visual basic programming and everything was fine until our topic shifted to arrays. I tried to understand it's code using Java. (Example: method are called functions.. .)
My prof has given us an exercise to create a Quiz program that asks the user more than 5 questions (in textbox) with choices (in buttons) and computes the score at the end (All just in one form). If the user click an a button it will tell if it's right or wrong and then proceed to change the question along with the choices.
*Required: - After the user finish the quiz the score will be displayed and there should be a restart button and all the question will be asked again randomly no pattern. - Try to make functions.
I tried searching the web since yesterday and I still have made no progress at my code.
Public Class Form1
Dim questions(5) As String
Dim answers(5) As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Method/Function for loading the Q&A
loadQsAndAs()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub loadQsAndAs()
'Questions
questions(0) = "What is 1 + 1?"
questions(1) = "Who is the first man to walk on the Moon?"
questions(2) = "What is the name of the main character in the movie: Yes Man! (2007)"
questions(3) = "If I gave you three apples and you ate two, how many is left?"
questions(4) = "What do you want in your final grade?"
questions(5) = "What is the name of the thing(s) that you use whenever you eat?"
'Answers
answers(0) = "2"
answers(1) = "Neil Armstrong"
answers(2) = "Jim Carrey"
answers(3) = "1"
answers(4) = "A 4.0"
answers(5) = "A Spoon and Fork"
TextBox1.Text = setTheQuestion()
Button1.Text = setTheAnswer1()
Button2.Text = setTheAnswer2()
Button3.Text = setTheAnswer3()
Button4.Text = setTheAnswer4()
End Sub
Private Function setTheQuestion() As String
Dim randomValue As New Random
Dim randomQ As String = ""
Dim i As Integer
Dim index As Integer
For i = 0 To 0
index = randomValue.Next(0, questions.Length)
randomQ &= questions(index)
Next
Return randomQ
End Function
Private Function setTheAnswer1() As String
Dim randomValue As New Random
Dim randomAns As String = ""
Dim i As Integer
Dim index As Integer
For i = 0 To 0
index = randomValue.Next(0, answers.Length)
randomAns &= answers(index)
Next
Return randomAns
End Function
Private Function setTheAnswer2() As String
Dim randomValue As New Random
Dim randomAns As String = ""
Dim i As Integer
Dim index As Integer
For i = 0 To 0
index = randomValue.Next(1, answers.Length)
randomAns &= answers(index)
Next
Return randomAns
End Function
Private Function setTheAnswer3() As String
Dim randomValue As New Random
Dim randomAns As String = ""
Dim i As Integer
Dim index As Integer
For i = 0 To 0
index = randomValue.Next(2, answers.Length)
randomAns &= answers(index)
Next
Return randomAns
End Function
Private Function setTheAnswer4() As String
Dim randomValue As New Random
Dim randomAns As String = ""
Dim i As Integer
Dim index As Integer
For i = 0 To 0
index = randomValue.Next(3, answers.Length)
randomAns &= answers(index)
Next
Return randomAns
End Function
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
loadQsAndAs()
End Sub
End Class
Public Class Form1
Dim questions As New ArrayList
Dim answers As New ArrayList
Dim dtQAMain As New DataTable
Dim questionsCopy As New ArrayList
Dim alAnsButton As New ArrayList 'arraylist to store all answer button.
Dim totalScore As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
'Method/Function for loading the Q&A
alAnsButton.Add(Button1)
alAnsButton.Add(Button2)
alAnsButton.Add(Button3)
alAnsButton.Add(Button4)
loaddtQA()
loadQsAndAs()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
Me.Close()
End Sub
Private Sub loaddtQA()
dtQAMain = New DataTable
dtQAMain.Columns.Add("Q")
dtQAMain.Columns.Add("A")
For i = 0 To 5
questions.Add("")
answers.Add("")
Next
'Questions
questions(0) = "What is 1 + 1?"
questions(1) = "Who is the first man to walk on the Moon?"
questions(2) = "What is the name of the main character in the movie: Yes Man!(2007)"
questions(3) = "If I gave you three apples and you ate two, how many is left?"
questions(4) = "What do you want in your final grade?"
questions(5) = "What is the name of the thing(s) that you use whenever you eat?"
'Answers
answers(0) = "2"
answers(1) = "Neil Armstrong"
answers(2) = "Jim Carrey"
answers(3) = "1"
answers(4) = "A 4.0"
answers(5) = "A Spoon and Fork"
For i = 0 To questions.Count - 1
dtQAMain.Rows.Add(questions(i), answers(i)) 'assign QA in table for scoring purpose later
Next
End Sub
Private Sub loadQsAndAs()
Label1.Visible = False
For i = 0 To alAnsButton.Count - 1
alAnsButton(i).visible = True
Next
questionsCopy = New ArrayList
questionsCopy = questions.Clone 'close a copy so we dont effect the actual question copy when randomize and eliminate asked question from arraylist
TextBox1.Text = setTheQuestion()
setTheAnswer()
End Sub
Private Function setTheQuestion() As String
Dim randomValue As New Random
Dim randomQ As String = ""
Dim index As Integer
If questionsCopy.Count <> 0 Then
index = randomValue.Next(0, questionsCopy.Count - 1)
randomQ = questionsCopy(index)
questionsCopy.RemoveAt(index) 'asked question will be remove.
Else ' questions are finished, show the mark
ShowMark()
End If
Return randomQ
End Function
Private Sub setTheAnswer() 'randonmize the answer and assign to button
If TextBox1.Text = "" Then Exit Sub ' if question finish exit sub
Dim randomValue As New Random
Dim NewIndex As Integer
Dim temp As String
Dim answersCopy As ArrayList = answers.Clone
For n = answersCopy.Count - 1 To 0 Step -1
NewIndex = randomValue.Next(0, n + 1)
' Swap them.
temp = answersCopy(n)
answersCopy(n) = answersCopy(NewIndex)
answersCopy(NewIndex) = temp
Next
Dim AnswerRowCheck As Integer = questions.IndexOf(TextBox1.Text)
Dim ActualAnswer As String = dtQAMain.Rows(AnswerRowCheck).Item("A") 'check actual answer
Dim totalRemove As Integer = 0
For i = answersCopy.Count - 1 To 0 Step -1
If totalRemove = 2 Then Exit For
If answersCopy(i) <> dtQAMain.Rows(AnswerRowCheck).Item("A") Then
answersCopy.RemoveAt(i)
totalRemove += 1
End If
Next 'remove 2 of the selection,since only 4 button for answer selection and should not take out the actual answer
For i = 0 To alAnsButton.Count - 1
alAnsButton(i).text = answersCopy(i)
Next
End Sub
Private Sub ShowMark()
For i = 0 To alAnsButton.Count - 1
alAnsButton(i).text = "" 'clear the text, no more input receive from user.
Next
Label1.Visible = True
Label1.Text = totalScore & " out of 6 are correct."
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
totalScore = 0
loadQsAndAs() 'refresh question
End Sub
Private Sub Button4_MouseClick(sender As Object, e As MouseEventArgs) Handles Button4.MouseClick, Button3.MouseClick, Button2.MouseClick, Button1.MouseClick
If sender.text = "" Then Exit Sub
Dim AnswerRowCheck As Integer = questions.IndexOf(TextBox1.Text) 'search question number
If dtQAMain.Rows(AnswerRowCheck).Item("A") = sender.text Then 'checking answer
totalScore += 1
End If
TextBox1.Text = setTheQuestion() 'next question
setTheAnswer()
End Sub
End Class
The code had cover most of the necessary comment which include the idea and how it work. Random() and arraylist are the key for this program to function, just pay more attention on it. Good luck.
How about trying this?
Public Class Form1
Dim questions(5) As String
Dim answers(5) As String
Private Sub loadQsAndAs()
'Questions
questions(0) = "What is 1 + 1?"
questions(1) = "Who is the first man to walk on the Moon?"
questions(2) = "What is the name of the main character in the movie: Yes Man! (2007)"
questions(3) = "If I gave you three apples and you ate two, how many is left?"
questions(4) = "What do you want in your final grade?"
questions(5) = "What is the name of the thing(s) that you use whenever you eat?"
'Answers
answers(0) = "2"
answers(1) = "Neil Armstrong"
answers(2) = "Jim Carrey"
answers(3) = "1"
answers(4) = "A 4.0"
answers(5) = "A Spoon and Fork"
Dim random As New Random
Dim indices = { 0, 1, 2, 3, 4, 5 }.OrderBy(Function (n) random.Next()).ToArray()
Dim question = random.Next(questions.Length - 1)
TextBox1.Text = questions(indices(question))
Button1.Text = answers(indices(0))
Button2.Text = answers(indices(1))
Button3.Text = answers(indices(2))
Button4.Text = answers(indices(3))
End Sub
End Class
That's it. Nice and simple. The key trick is creating a randomize indices array to do the lookups into the questions and answers arrays.
Private Dim rnd As Integer
Private Function setTheQuestion() As String
rnd = (CInt(Math.Ceiling(Rnd() * questions.Length)) + 1)
Return questions(rnd)
End Function
Private Function setTheAnswer1() As String
Return answers(rnd)
End Function

Score not being calculated correctly

Hi I'm created a program for a project and I've now started running some tests and the score for the user isn't being calculated correctly and I believe that it can't compare the answer given to the correct answer. I'm very confused and need any help that can be given. My code looks like this, any confusing parts and I'll try and explain.
Imports System.IO
Public Class QuestionScreen
Dim score As Integer = 0
Dim count As Integer
Dim Difficulty_ext As String
Dim questions, answers As New List(Of String)()
Private i As Integer
Sub ReadFile()
If Main.Diff_DDown.Text = "Easy" Then
Difficulty_ext = "questions - Easy"
ElseIf Main.Diff_DDown.Text = "Medium" Then
Difficulty_ext = "questions - Medium"
Else
Difficulty_ext = "questions - Difficult"
End If
Randomize()
Dim countline = File.ReadAllLines("c:\Users\Alice\Desktop\programme files\" & Difficulty_ext & ".txt").Length
Dim numline As Integer
Dim values() As String
Using sr As New StreamReader("c:\Users\Alice\Desktop\programme files\" & Difficulty_ext & ".txt")
While Not sr.EndOfStream
values = sr.ReadLine().Split(","c)
questions.Add(values(0))
answers.Add(values(1))
End While
End Using
numline = Int(Rnd() * countline)
For i As Integer = 0 To numline
Question.Text = questions(i)
Act_ANS.Text = answers(i)
Next
End Sub
Private Sub Pass_Btn_Click(sender As Object, e As EventArgs) Handles Pass_Btn.Click
If count < 10 Then
Call ReadFile()
count = count + 1
Ans_TxtBx.Text = ""
Hid_Score.Text = score
Else
ResultsScreen.Show()
Me.Hide()
End If
End Sub
Public Sub Submit_Btn_Click(sender As Object, e As EventArgs) Handles Submit_Btn.Click
If count < 10 Then
Call ReadFile()
count = count + 1
If Ans_TxtBx.Text = answers(i) Then
score = score + 1
End If
Hid_Score.Text = score
Else
ResultsScreen.Show()
Me.Hide()
count = 0
End If
Ans_TxtBx.Text = ""
End Sub
Private Sub QuestionScreen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call ReadFile()
End Sub
End Class
OK..... Try this, I have debugged your code trying to leave it pretty much as you had it, there were a number of problems, nothing major just a few lines of code in the wrong place....
Imports System.IO
Public Class Form1
Dim score As Integer = 0
Dim count As Integer
Dim Difficulty_ext As String
Dim questions, answers As New List(Of String)()
Private i As Integer
Sub ReadFile()
If Diff_DDown.Text = "Easy" Then
Difficulty_ext = "questions - Easy"
ElseIf Diff_DDown.Text = "Medium" Then
Difficulty_ext = "questions - Medium"
Else
Difficulty_ext = "questions - Difficult"
End If
Randomize()
Try
Dim countline = File.ReadAllLines("c:\Users\Alice\Desktop\programme files\" & Difficulty_ext & ".txt").Length
Dim numline As Integer
Dim values() As String
' clear the list of questions and answers
answers.Clear()
questions.Clear()
'''''''''''''''''''''''''''''''''''''''''
Using sr As New StreamReader("c:\Users\Alice\Desktop\programme files\" & Difficulty_ext & ".txt")
While Not sr.EndOfStream
values = sr.ReadLine().Split(","c)
questions.Add(values(0))
answers.Add(values(1))
End While
End Using
numline = Int(Rnd() * countline)
For i = 0 To numline
Question.Text = questions(i)
Act_ANS.Text = answers(i)
Next
Catch ex As Exception
End Try
End Sub
Private Sub Pass_Btn_Click(sender As Object, e As EventArgs) Handles Pass_Btn.Click
If count < 10 Then
count = count + 1
Ans_TxtBx.Text = ""
Hid_Score.Text = score
Else
ResultsScreen.Show()
Me.Hide()
End If
Call ReadFile() ' move this to the bottom
End Sub
Public Sub Submit_Btn_Click(sender As Object, e As EventArgs) Handles Submit_Btn.Click
If count < 10 Then
count = count + 1
If Ans_TxtBx.Text = answers(i - 1) Then ' need to subtract 1 here
score = score + 1
End If
Hid_Score.Text = score
Else
ResultsScreen.Show()
Me.Hide()
count = 0
End If
Ans_TxtBx.Text = ""
Call ReadFile() ' move this to the bottom
End Sub
Private Sub QuestionScreen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call ReadFile()
End Sub
End Class

Trouble With State/Capital Matching Program In VB

Alright, so the program is set up where you have a set of radio buttons with 5 states, and another set of 5 with 5 capitals. There's a button which tells you if they match or not. However I have to do it a certain way where clicking a radio button assigns a variable to both 'strCapital' and 'strChoice' and you compare them to see if they match.
I've tried to figure everything out (since it sounds easy in theory) but I've hit a wall.
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Dim strCapital As String
Dim strChoice As String
Dim strLittleRock As String
Dim strSpringfield As String
Dim strFrankfort As String
Dim strSalem As String
Dim strMadison As String
Private Sub radArkansas_CheckedChanged(sender As Object, e As EventArgs) Handles radArkansas.CheckedChanged
strCapital = strLittleRock
End Sub
Private Sub radIllinois_CheckedChanged(sender As Object, e As EventArgs) Handles radIllinois.CheckedChanged
strCapital = strSpringfield
End Sub
Private Sub radSpringfield_CheckedChanged(sender As Object, e As EventArgs) Handles radSpringfield.CheckedChanged
strChoice = strSpringfield
End Sub
Private Sub btnVerify_Click(sender As Object, e As EventArgs) Handles btnVerify.Click
If strCapital = strChoice Then
lblMsg.Text = "Correct"
ElseIf strCapital <> strChoice Then
lblMsg.Text = "Incorrect"
End If
End Sub
Private Sub radLittleRock_CheckedChanged(sender As Object, e As EventArgs) Handles
radLittleRock.CheckedChanged
strChoice = strLittleRock
End Sub
End Class
EDIT: Also I forgot to mention the main problem which is always a bad thing. Basically whenever I run it and enter something incorrect (checking Arkansas and Springfield for example) it always says it's correct.
I did something similar... you can modify this code:
Private Sub btnAmIRight_Click(sender As Object, e As EventArgs) Handles btnAmIRight.Click
' displays if submission is correct
' declare variables
Dim strAmIRight As String
Dim dblMatch As Double
If rbtnAlabama.Checked = True And rbtnMontgomery.Checked = True Then
dblMatch = 1
ElseIf rbtnAlaska.Checked = True And rbtnJuneau.Checked = True Then
dblMatch = 1
ElseIf rbtnArizona.Checked = True And rbtnPhoenix.Checked = True Then
dblMatch = 1
ElseIf rbtnArkansas.Checked = True And rbtnLittleRock.Checked = True Then
dblMatch = 1
ElseIf rbtnCalifornia.Checked = True And rbtnSacramento.Checked = True Then
dblMatch = 1
ElseIf rbtnColorado.Checked = True And rbtnDenver.Checked = True Then
dblMatch = 1
ElseIf rbtnConnecticut.Checked = True And rbtnHartford.Checked = True Then
dblMatch = 1
ElseIf rbtnDelaware.Checked = True And rbtnDover.Checked = True Then
dblMatch = 1
ElseIf rbtnFlorida.Checked = True And rbtnTallahassee.Checked = True Then
dblMatch = 1
ElseIf rbtnGeorgia.Checked = True And rbtnAtlanta.Checked = True Then
dblMatch = 1
Else
dblMatch = 0
End If
' assign code to variable
If dblMatch = 1 Then
strAmIRight = "Correct"
ElseIf dblMatch = 0 Then
strAmIRight = "Try Again"
End If
' display result
lblResult.Text = strAmIRight.ToString
End Sub

How to have Marquee kind of text in vb.net?

Is there any way to make the text in a Windows Form to scroll like the text in a marquee tag in HTML?
You can use a timer and a couple of variables to help you do so. Something like this can be done...
'Class-level variables.
Private m_intMarqueeCounter As Integer = 1
Private m_bolMarqueeIncrementUp As Boolean = True
Private Sub YourMarqueeTimer_Tick()
'You can decide what number is best for your app.
If m_intMarqueeCounter = 10 Then
m_bolMarqueeIncrementUp = False
End If
If m_intMarqueeCounter = 0 Then
m_bolMarqueeIncrementUp = True
End If
Dim intX As Integer
For intX = 0 to m_intMarqueeCounter
frmYourForm.Text = " " & "Your Title"
Next
If m_bolMarqueeIncrementUp Then
m_intMarqueeCounter += 1
Else
m_intMarqueeCounter -= 1
End If
End Sub
Const marqueeText As String = "The quick brown fox... "
Dim sb As New System.Text.StringBuilder
Dim direction As Boolean = False 'true = left to right, false = right to left
Private Sub Timer1_Tick(sender As System.Object, _
e As System.EventArgs) Handles Timer1.Tick
If sb.Length = 0 Then sb.Append(marqueeText)
If direction Then
sb.Insert(0, sb(sb.Length - 1))
sb.Remove(sb.Length - 1, 1)
Else
sb.Append(sb(0))
sb.Remove(0, 1)
End If
Me.Text = sb.ToString
End Sub