PDA

View Full Version : Noob needs help with vb code!



dean_wat
09-28-2007, 08:38 AM
I am trying to write code that uses a select case that ask whether or not to add, subtract, multiply or divide the two numbers. Here is what I already have, can anyone please help me.:banghead:


Option Compare Database
Option Explicit

Sub Numbers()

Dim intNum1 As Integer
Dim intNum2 As Integer
Dim intAnswer As Double
Dim Math As Integer

intNum1 = InputBox("Enter the first number: ")
intNum2 = InputBox("Enter the second number: ")

Select Case Math
Case 1
intAnswer = intNum1 + intNum2
Case 2
intAnswer = intNum1 - intNum2
Case 3
intAnswer = intNum1 / intNum2
Case 4
intAnswer = intNum1 * intNum2

End Select

MsgBox "The answer of the numbers entered is" & intAnswer
End Sub


EDIT: Added Code tags Tommy

Norie
09-28-2007, 08:50 AM
dean

Where are you actually setting/getting a value for Math?

PS You really shouldn't use Math as a variable name, that's a VBA class.:)

dean_wat
09-30-2007, 05:55 PM
Thank You I got it.