ok i have a program tah randomizes number adn signs (+,-). i made it
so little kids can learn math easily and i wouldn't have to write each
question out.
when the plus sign is used, eveyrthing works fine because they just
add the two numbers. when the computer chooses the minus sign,
sometimes the first number is smaller then the second and the kids
cant do it because they do not know negative numbers.
so my question is, how do i make sure that the first number (num1) is
always bigger then (num2)?
i have a "next" button to ask for the next question, when the user
presses it, the computer tells the user if its right or wrong and
gives the next question.
here is my code:
Dim num1 As Integer 'first number
Dim num2 As Integer 'second number
Dim sign(2) As String 'the sign that will be used
Private Sub Form_Load()
sign(0) = "+"
sign(1) = "-"
Randomize
'randomize the computer
lblNum1.Caption = Int(20 * Rnd)
num1 = lblNum1.Caption
'randomize num1 and store value
lblNum2.Caption = Int(20 * Rnd)
num2 = lblNum2.Caption
'randomize num2 and store value
lblSign.Caption = sign(Int(2 * Rnd))
'randomize sign
End Sub
Private Sub cmdNext_Click()
If lblSign.Caption = "+" Then
If Val(txtAnswer.Text) = Val(num1 + num2) Then
MsgBox ("Great Job")
ElseIf Val(txtAnswer.Text) <> Val(num1 + num2) Then
MsgBox "Look at the numbers carefully next time!",
vbExclamation
End If
ElseIf lblSign.Caption = "-" Then
If Val(txtAnswer.Text) = Val(num1 - num2) Then
MsgBox ("Great Job")
ElseIf Val(txtAnswer.Text) <> Val(num1 + num2) Then
MsgBox "Look at the numbers carefully next time!",
vbExclamation
End If
End If
Randomize
'randomize the computer
lblNum1.Caption = Int(20 * Rnd)
num1 = lblNum1.Caption
'randomize num1 and store value
lblNum2.Caption = Int(20 * Rnd)
num2 = lblNum2.Caption
'randomize num2 and srote value
lblSign.Caption = sign(Int(2 * Rnd))
'randomize sign
txtAnswer.Text = ""
End Sub