Math Functions
Abs([expr]))
Returns the absolute value of a specified expression.
Example:
Dim myNumb as Double
myNumb = Abs(3.14159)
' myNumb = 3
myNumb = Abs(-42)
' myNumb = 42
Int([expr]))
Fix([expr]))
Returns the integer part of a specified expression.
The difference between Int() and Fix() functions is that if the number is negative, Int() returns the first negative number less than or equal to Number whereas Fix() returns the first negative integer greater than or equal to Number.
Example:
Dim myNumb2 as Integer
' declare as double so the variable can store a decimal portion of a number.
Dim pi as Double
pi = 3.14159
myNumb = Int(pi)
myNumb2 = Fix(pi)
' myNumb = 3
' myNumb2 = 3
' declare as double so the variable can store a decimal portion of a number.
Dim npi as Double
npi = -3.14159
myNumb = Int(npi)
myNumb2 = Fix(npi)
' myNumb = -4
' myNumb2 = -3
Randomize()
Rnd([number])
Generate a random number. The number is always less than 1 but greater than 0.
The [number] field is optional. the [number] field is to seed the random number generator. use Randomize() to generate a random seed. setting the [number] field will generate the same set of random numbers each time Rnd() is called.
Example: (this could be made to a function of it's own)
Dim min as Integer
Dim max as Integer
Dim rNumb as Integer
' set our variables
min = 1
max = 100
' generate random seed.
Randomize
' generate a random number.
rNumb = Int((max - min + 1) * Rnd() + min)
' rNumb now contains a random number between 1 and 100.
Sqr([number]))
Returns the square root of number.
Example:
Dim myNumb as Double
myNumb = Sqr(9)
' myNumb = 3
myNumb = Sqr(47)
' myNumb = 6.85565460040104
Cos([angle]))
Sin([angle]))
Tan([angle]))
Atn([angle]))
Geomotry functions to calculate Cosine, Sine, Tangent, and Arctangent.