Results 1 to 4 of 4

Thread: Adding two numbers (I just forgot how)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Talking

    How do u add 2 numbers together and how do u subtract two numbers!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  2. #2
    Guest
    Add: Val(number1) + Val(number2)
    Subtract: Val(number1) - Val(number2)

  3. #3
    Guest
    1) You don't need to use Val, unless you are converting from a String.
    2) You need the value to be assigned to another variable.

    Code:
    'Add
    Num3 = Num1 + Num2
    
    'Subtract
    Num3 = Num1 - Num2

  4. #4
    Guest
    I don't think it'd matter though. Only reason I put Val was because number + number or number - number doesn't always give the right result. Ever see that problem before, Megatron?

    And I do know that it has to be assigned to something else. Not always a variable.

    msgbox num1 + num2

    But he just wanted to be shown how to add and subtract.


    VIP3R: Amnesia?

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