Consulting

Results 1 to 3 of 3

Thread: Noob needs help with vb code!

  1. #1
    VBAX Newbie
    Joined
    Sep 2007
    Posts
    4
    Location

    Noob needs help with vb code!

    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.

    [VBA]
    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
    [/VBA]

    EDIT: Added Code tags Tommy

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    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.

  3. #3
    VBAX Newbie
    Joined
    Sep 2007
    Posts
    4
    Location
    Thank You I got it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •