Results 1 to 4 of 4

Thread: Simple Math Functions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2003
    Posts
    29

    Simple Math Functions

    Hey, I'm kind of new kind of not to programing, I know basic syntax's and all that, but for some reason I can't get a simple addition function to work. I'm trying to make a very simple calculator for my first project. It irretates me so much that subtraction, multiplication, division all work but not addition. It does 1+1=11, 25+4=254, etc... Any help? Here's the code:

    Private Sub Add_bttn_Click()
    Numb_3 = Numb_1 + Numb_2
    End Sub
    Private Sub Div_Bttn_Click()
    Numb_3 = Numb_1 / Numb_2
    End Sub
    Private Sub Mul_Bttn_Click()
    Numb_3 = Numb_1 * Numb_2
    End Sub
    Private Sub Sub_Bttn_Click()
    Numb_3 = Numb_1 - Numb_2
    End Sub
    Look through your dreams through a mirror,

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    Declare numb_1 , numb_2 and numb_3 as integers. The problem will (should) be solved

  3. #3
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    Villiers, South Africa
    Posts
    301
    I think the following should work as well:
    Numb_3 = VAL(Numb_1)+VAL(Numb_2)

  4. #4
    Lively Member Professor29's Avatar
    Join Date
    Feb 2002
    Posts
    89
    Try this:

    Code:
    Function Add(Num1, Num2)
        Num3 = Num1 + Num2
        Return Num3
    End Function
    My syntax is probably screwed up, due to the fact that I don't have anything to write it in.
    ERROR: No keyboard detected. Hit F1 to continue.

Posting Permissions

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



Click Here to Expand Forum to Full Width