Input Box Processing troubles
What am I doing wrong in the following. I can't get the If...Then...Else
statement to do.
Private Sub cmdGetNums_Click()
Dim num1 As Single
Dim num2 As Single
Dim doWhat As String
Dim answer As Single
num1 = Val(InputBox("Enter first number.", "First Number"))
num2 = Val(InputBox("Enter second number.", "Second Number"))
doWhat = InputBox("Enter add, subtract, multiply or divide")
Call doWithNums
End Sub
Private Sub doWithNums()
If doWhat = add Then
answer = num1 + num2
ElseIf doWhat = subtract Then
answer = num1 - num2
ElseIf doWhat = multiply Then
answer = num1 * num2
Else: answer = num1 / num2
MsgBox ("The answer is " & answer)
End If
End Sub
Thanks in advance
Sandy
|