kenyi

01-14-2004, 02:14 PM

I wan to make a calculator. Can anyone else tell me some mathematical commands??

View Full Version : Visual Basic: Maths?

kenyi

01-14-2004, 02:14 PM

I wan to make a calculator. Can anyone else tell me some mathematical commands??

scroots

01-14-2004, 06: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)

a=25

b=5

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

a=30

b=6

print a*b

print a+b

print a-b

there are other operations you can do.

scroots

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)

a=25

b=5

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

a=30

b=6

print a*b

print a+b

print a-b

there are other operations you can do.

scroots

shmoove

01-14-2004, 07: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.

shmoove

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

shmoove

Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.