LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Troubles Jonas Krogh Excel Discussion (Misc queries) 1 October 22nd 09 11:14 AM
Interupt processing Dave597 Excel Discussion (Misc queries) 0 April 18th 08 08:07 PM
COM Add-in Troubles Howard Excel Discussion (Misc queries) 0 May 22nd 07 01:59 PM
IF troubles JG Excel Worksheet Functions 6 December 24th 06 04:58 AM
Data Processing Sedat Excel Programming 0 September 29th 03 05:22 PM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"