Siebel VB Language Reference > VB Language Reference >
CInt Function
This standard VB function converts an expression to the data type integer by rounding. Syntax
CInt(expression)
|
|
expression |
Any expression that evaluates to a number |
Returns
The value of expression as an integer. Usage
After rounding, the resulting number must be within the range of -32767 to 32767, or an error occurs. Strings that cannot be converted to an integer result in a Type Mismatch error. Variants containing null result in an Illegal Use of Null error. Example
This example calculates the average of ten golf scores. Sub Button_Click Dim score As Integer Dim x, sum Dim msgtext Let sum = 0 For x = 1 to 10 score = 7- sum = sum + score Next x msgtext = "Your average is: " & _ Format(CInt(sum/ (x - 1)), "General Number") End Sub
Related Topics
CCur Function CDbl Function CLng Function CSng Function CStr Function CVar Function CVDate Function
|