avatar

Vb Code For Formatting Decimal Values

Asked By 10 points N/A Posted on -
qa-featured

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

SHARE
Answered By 0 points N/A #100567
qa-featured

Two depending can be used according to your desire.

  1. FormatNumber Returns an expression formatted as a number
  2. 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

Login/Register to Answer

Related Questions