If/Then/Else with Comparison operators
Sub NumberGuess()
Dim userGuess As Integer
Dim answer As Integer
answer = Rnd * 10
userGuess = 12
If (userGuess > answer) Then
MsgBox ("Too high!")
MsgBox ("The answer is " & answer)
End If
If (userGuess < answer) Then
MsgBox ("Too low!")
MsgBox ("The answer is " & answer)
End If
If (userGuess = answer) Then MsgBox ("You got it!")
End Sub
Related examples in the same category