I am currently taking a class for Excel Vba, and have an assignment. I have tried everything I can think of, but can't get the calculations to work. In the AddUserInput procedure I am suppose to use a Select Case Structure to decide which math operation to use, also include a CASE ELSE to print an error message if an invalid math operation is entered by the user. I can get all of the inputboxes to show, but nothing happens and I don't know how to correctly format the Select case/case else structure. Any help would be greatly appreciated.
Option Explicit
Dim answer As Integer
Dim num1 As Integer
Dim num2 as Integer
Dim Mathoperation As String
Private Sub Main()
num1 = Val(InputBox("Please enter the first operand", "First operand"))
num2 = Val(InputBox("Please enter the second operand", "Second operand"))
Mathoperation = Val(InputBox("+,-,*, or / for math operation", "Math Operation"))
Call AddUserInput(num1, num2)
SendResult
End Sub
Private Sub AddUserInput(num1 As Integer, num2 As Integer)
answer = num1 + num2
End Sub
Private Sub SendResult()
MsgBox ("The answer is " & Str(answer))
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call Main
End Sub
Bookmarks