WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG.
Public Class Form1
Dim r As Random = New Random
Dim no1, no2 As Integer
Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs)
Handles rdbAdd.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor = Color.White
no1 = randomInt()
no2 = randomInt()
lblOperation.Text = "+"
txtNumber1.Text = no1.ToString()
txtNumber2.Text = no2.ToString()
End Sub
Public Function randomInt() As Integer
Return r.Next(20, 120)
End Function
Private Sub rdbSub_CheckedChanged(sender As Object, e As
EventArgs) Handles rdbSub.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor = Color.White
no1 = randomInt()
no2 = randomInt()
lblOperation.Text = "-"
txtNumber1.Text = no1.ToString()
txtNumber2.Text = no2.ToString()
End Sub
Private Sub rdbMul_CheckedChanged(sender As Object, e As
EventArgs) Handles rdbMul.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor = Color.White
no1 = randomInt()
no2 = randomInt()
lblOperation.Text = "*"
txtNumber1.Text = no1.ToString()
txtNumber2.Text = no2.ToString()
End Sub
Private Sub rdbDiv_CheckedChanged(sender As Object, e As
EventArgs) Handles rdbDiv.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor = Color.White
no1 = randomInt()
lblOperation.Text = "/"
txtNumber1.Text = no1.ToString()
Do
no2 = randomInt()
If no1 Mod no2 = 0 Then
Exit Do
End If
Loop
txtNumber2.Text = no2.ToString()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs)
Handles btnExit.Click
'Close the form'
Me.Close()
End Sub
Private Sub btnCheckAns_Click(sender As Object, e As EventArgs)
Handles btnCheckAns.Click
Dim userAnswer = txtAnswer.Text
Try
Integer.TryParse(txtAnswer.Text, userAnswer)
If rdbAdd.Checked = True Then
If Val(txtAnswer.Text) = no1 + no2 Then
txtAnswer.BackColor = Color.Green
Else
txtAnswer.BackColor = Color.Red
End If
End If
If rdbSub.Checked = True Then
If Val(txtAnswer.Text) = no1 - no2 Then
txtAnswer.BackColor = Color.Green
Else
txtAnswer.BackColor = Color.Red
End If
End If
If rdbMul.Checked = True Then
If Val(txtAnswer.Text) = no1 * no2 Then
txtAnswer.BackColor = Color.Green
Else
txtAnswer.BackColor = Color.Red
End If
End If
If rdbDiv.Checked = True Then
End If
If Val(txtAnswer.Text) = no1 / no2 Then
txtAnswer.BackColor = Color.Green
Else
txtAnswer.BackColor = Color.Red
End If
Catch ex As Exception
MsgBox("Please enter Intger")
End Try
End Sub
End Class
Below is the solution:
code:
Public Class Form1
Dim r As Random = New Random
Dim no1, no2 As Integer
Dim rightAnswer As Integer = 0
Dim wrongAnswer As Integer = 0
Private Sub Form1_Load(sender As Object, e As
EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCheckAns_Click(sender As
Object, e As EventArgs) Handles btnCheckAns.Click
Dim userAnswer =
txtAnswer.Text
Try
Integer.TryParse(txtAnswer.Text, userAnswer)
If rdbAdd.Checked = True Then
MessageBox.Show(no1 + no2 & " " & txtAnswer.Text)
If Val(txtAnswer.Text) = no1 + no2 Then
txtAnswer.BackColor = Color.Green
rightAnswer = rightAnswer + 1 'increment the right answer
value
Else
txtAnswer.BackColor = Color.Red
wrongAnswer = wrongAnswer + 1 'increment the wrong answer
value
End If
End If
If rdbSub.Checked = True Then
If Val(txtAnswer.Text) = no1 - no2 Then
txtAnswer.BackColor = Color.Green
rightAnswer = rightAnswer + 1 'increment the right answer
value
Else
txtAnswer.BackColor = Color.Red
wrongAnswer = wrongAnswer + 1 'increment the wrong answer
value
End If
End If
If rdbMul.Checked = True Then
If Val(txtAnswer.Text) = no1 * no2 Then
txtAnswer.BackColor = Color.Green
rightAnswer = rightAnswer + 1 'increment the right answer
value
Else
txtAnswer.BackColor = Color.Red
wrongAnswer = wrongAnswer + 1 'increment the wrong answer
value
End If
End If
If rdbDiv.Checked = True Then
End If
If Val(txtAnswer.Text) = no1 / no2 Then
txtAnswer.BackColor = Color.Green
rightAnswer = rightAnswer + 1 'increment the right answer
value
Else
txtAnswer.BackColor = Color.Red
wrongAnswer = wrongAnswer + 1 'increment the wrong answer value
End If
Catch ex As
Exception
MsgBox("Please enter Intger")
End Try
End Sub
Private Sub rdbAdd_CheckedChanged(sender As
Object, e As EventArgs) Handles rdbAdd.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor =
Color.White
no1 = r.Next(10)
no2 = r.Next(10)
lblOperation.Text =
"+"
txtNumber1.Text =
no1.ToString()
txtNumber2.Text =
no2.ToString()
End Sub
Private Sub rdbSub_CheckedChanged(sender As
Object, e As EventArgs) Handles rdbSub.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor =
Color.White
no1 = r.Next(10)
no2 = r.Next(10)
lblOperation.Text =
"-"
txtNumber1.Text =
no1.ToString()
txtNumber2.Text =
no2.ToString()
End Sub
Private Sub rdbDiv_CheckedChanged(sender As
Object, e As EventArgs) Handles rdbDiv.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor =
Color.White
no1 = r.Next(10)
lblOperation.Text =
"/"
txtNumber1.Text =
no1.ToString()
Do
no2 = r.Next(10)
If no1 Mod no2 = 0 Then
Exit Do
End If
Loop
txtNumber2.Text =
no2.ToString()
End Sub
Private Sub rdbMul_CheckedChanged(sender As
Object, e As EventArgs) Handles rdbMul.CheckedChanged
txtAnswer.Clear()
txtAnswer.BackColor =
Color.White
no1 = r.Next(10)
no2 = r.Next(10)
lblOperation.Text =
"*"
txtNumber1.Text =
no1.ToString()
txtNumber2.Text =
no2.ToString()
End Sub
Private Sub btnExit_Click(sender As Object, e
As EventArgs) Handles btnExit.Click
'message box display
with right answer and wrong answer value
MessageBox.Show("Right
Answer: " & rightAnswer & vbNewLine & "Wrong Answer: "
& wrongAnswer)
'Close the form'
Me.Close()
End Sub
End Class
WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING,...
so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...
Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards. Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...
I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...
I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...
The Murach's Visual Basic 2015 Book And Visual Studio Exercise 7-2 Enhance the Invoice Total application If you did exercise 6-1 in the last chapter, this exercise asks you to add data validation and exception handling to it. 1. Copy the Invoice Total application from your C:\VB 2015\Chapter 06 directory to your Chapter 07 directory. This should be your solution to exercise 6-1 of the last chapter. 2. If your application has both a Sub procedure and a Function procedure...
Any way to add a counter?, to count the elements/ # of prime factors outputted to TextBox2.Text. VB Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.click Dim n As Long Dim i As Long Dim k As Long Dim Prime As Boolean n = TextBox1.Text For i = 2 To n If n Mod i = 0 Then k = 2 Prime = False While k <i / 2 If i Mod k = 0...
Public Class Form1 Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click Dim room As Double 'Assigns room as double Dim rate As Double 'Assigns rate as double Dim room2 As Double 'Assigns room as double Dim overallRate As Double 'Assigns overall as double Dim a As Integer 'Assign a as an integer For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors With...
I’m attempting to create the functioning GUI (bottom photo) from the coding in the first photo. I’m unclear as to what I’m missing to complete the code. Thank you a Homework 8 similar to Exercise 16 8.pdf (page 1 of 2) Public Class Formi Dim answer As Integer Sub Random() Dim random As New Random() answer randon.Next (1, 1ee) End Sub Private Sub Formi Load(ByVal sender As System.Object, Byval e As System. EventArgs) Handles MyBase. Load Random() End Sub Private...
Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...
Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the VB2015\Chap10\Zander Solution\Zander Solution (Zander Solution.sln) file. Open the Employees.txt file, which is contained in the project’s bin\Debug folder. The ID and salary information appear on separate lines in the file. Close the Employees.txt window. a. Define a structure named Employee. The structure should contain two member variables: a String variable to store the ID and a Double variable to store the salary. b. Declare...