Siebel VB Language Reference > VB Language Reference >
Fix Function
This standard VB function returns the integer part of a number. Syntax
Fix(number)
|
|
number |
Any valid numeric expression |
Returns
The integer part of number. Usage
The return value's data type matches the type of the numeric expression. This includes variant expressions, unless the numeric expression is a string (vartype 8) that evaluates to a number, in which case the data type for its return value is vartype 5 (double). If the numeric expression is vartype 0 (empty), the data type for the return value is vartype 3 (long). For both positive and negative numbers, Fix removes the fractional part of the expression and returns the integer part only. For example, Fix (6.2) returns 6; Fix (-6.2) returns -6. The effect of this function is the same as that of the Int function, except in the handling of negative numbers. Thus:
- Fix(-8.347) = -8
- Int(-8.347) = -9
Example
This example returns the integer portion of a number provided by the user. Sub Button_Click Dim usernum Dim intvalue usernum = 77.54 intvalue = Fix(usernum) End Sub
Related Topics
Abs Function CInt Function Exp Function Int Function Log Function Rnd Function Sgn Function Sqr Function
|