View Full Version : Visual Basic: Maths?

01-14-2004, 03:14 PM
I wan to make a calculator. Can anyone else tell me some mathematical commands??

01-14-2004, 07:32 PM
which commands to you know, i do VB at college, tis going quite slowly but i know the following:

Dim a as integer 'Declares variable a as integer (whole number)
Dim b as integer 'Declares variable b as integer (whole number)

There are different types of variables, long i think hold a number that can include decimals so

Dim a as long 'Declares variable a as long (number with decimals)
Dim b as long 'Declares variable b as long (number with decimals)

then you can do the following:
(basically normal maths stuff)

print str(a) & "divided by" &str(b) &"equals "& str(25/5)

str(variablename) makes the variable act like a string in the instance it is used.

so some more maths

print a*b
print a+b
print a-b

there are other operations you can do.


01-14-2004, 08:36 PM
Dim a as long 'Declares variable a as long (number with decimals)

A Long doesn't have any decimals. It just whole number with a bigger range than an Integer.


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum