# VB-Math

### Math,

Val function
Description
Returns the numbers contained in a string as a numeric value of appropriate type.

Syntax
Val(string)

The required string argument is any valid string expression.

The Val function stops reading the string at the first character it can’t recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from the argument.

Round
Description
Returns a number rounded to a specified number of decimal places.

Syntax
Round(expression [,numdecimalplaces])

The Round function syntax has these parts:

Example
Text1.Text = Number
Round(Number,5)        ‘Rounds the number in text1 to 5 decimal places

Int and Fix functions
Returns the integer portion of a number.

Syntax
Int(number)
Fix(number)

The required number argument is a Double or any valid numeric expression. If number contains Null, Null is returned.

Both Int and Fix remove the fractional part of number and return the resulting integer value. The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number, whereas Fix returns the first negative integer greater than or equal to number. For example,Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Rnd and Randomize functions
A function which generates a random number.
Randomize uses number to initialize the Rnd function’s random-number generator, giving it a new seed value. If you omit number, the value returned by the system timer is used as the new seed value.

Syntax
Randomize [number]
Rnd[(number)]

Example:
Randomize
Label1 = Int((6 * Rnd) + 1) ‘Generate random value between 1 and 6.

Sgn function
Returns a Variant (Integer) indicating the sign of a number.

Syntax
Sgn(number)

The required number argument can be any valid numeric expression. 