1. Laboratory Activity 3 (Batch 2)
Multiplication Program
Public Class Form1
Private num1 As Integer
Private num2 As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
GenerateRandomQuestion()
End Sub
Sub GenerateRandomQuestion()
Dim objRandom As Random = New Random()
num1 = objRandom.Next(1, 10)
num2 = objRandom.Next(1, 10)
Label4.Text = "How much is " & num1 & " times " & num2 & "?"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
GenerateRandomQuestion()
Label3.Text = " "
TextBox1.Clear()
'disable New Question button
Button2.Enabled = False
'enable verify button
Button1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim prod As Integer
prod = TextBox1.Text
If (num1 * num2) = prod Then
Label3.Text = "You Got the correct answer!!"
2. 'disable Verify button
Button1.Enabled = False
'enable Next Question button
Button2.Enabled = True
Else
Label3.Text = "Please Try Again"
End If
End Sub
End Class