Asked By
fernerich
10 points
N/A
Posted on - 04/13/2012
Hi TechyV!
I have a variable named total and its data type is currency.
Everytime an item is inserted in the flex grid, the total increases by adding the items prices.
But there are some instances that decimal points are too long.
How can I change the decimal point format on it?
For example:
25.3333 –> 25.33
VB code for formatting decimal values
Two depending can be used according to your desire.
-
FormatNumber Returns an expression formatted as a number
-
FormatCurrency Returns an expression formatted as a number with a leading currency symbol ($)
Following is Syntax for FormatNumber
FormatNumber (Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])
The syntax for FormatCurrency is exactly the same as the one above.
The number of digits after the decimal point can be specify like this
Dim dblTestNum As Double
dblTestNum = 1000.6666
// using FormatNumber
FormatNumber(dblTestNum, 2, True, True, True)
Output: 1000.66
Hope It will help You