Round Function

Category: GUI » Visual Basic 6 » Function

Description: Returns a number rounded to a specified number of decimal places Syntax: Round(expression [,numdecimalplaces])

ParametersDescription
expression Required. Numeric expression being rounded
numdecimalplaces Optional. Default 0. Number indicating how many places to the right of the decimal are included in the rounding

Return Data Type: Variant (Integer, Long, Single, Double) Usage / Example Code:

StatementResult / ValueRemark / Note
round(1.4) 1  
round(1.5) 2  
round(2.5) 2 Nearest even number
round(2.6) 3  
round(0.0035, 3) 0.004  
round(0.0045) 0.004 Nearest even digit
round(2.5, 1) 2.5  
round(1234.5678, 3) 1234.568  
round(123.5678) 124  
round(123.4567) 123  
round(-1.4) -1  
round(-1.5) -2  
round(-2.5) -2 Nearest even number
round(-2.6) -3  
round("123.4567") 123 input number as string
round(unknown) 0 Uninitialized variable
round(null) Null  
round("string") Error Run-time error '13': Type mismatch

Related Articles:

Tags: Math Functions, vb6