No of visitors who read this post: 454
Category: Visual basic
Type: Question
Author: Fernerich
No votes yet

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

# Comment Id: 54214

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