gdzanko
New Contributor
12 years ago

# Rounding currency

I am new to SmartBear and need to round the decimal part of currency and am not sure how to do this in Visual Basic. If I use the round method it will round to the nearest whole number but that is not what I need. I need it to round just the decimal part of the number instead. For example 7.125 would need to be rounded to 7.13. How can I do this in Test Complete?

### 4 Replies

• Anonymous

Hi Gina,

`//Use this function to round the decimal part of the numberFunction MathRound(X, I)   MathRound = Int(X * 10 ^ I + 0.5) / 10 ^ IEnd FunctionSub Main()  Log.Message(MathRound(7.125, 2))End Sub`

Is this what you need?
• VLapidus
Frequent Contributor
Call the Round function with the second parameter that stand for the number of digits after the delimiter included in the rounding:

Call Round(7.125, 2)
• Anonymous

Hi Gina,

• gdzanko
New Contributor
The Round function uses the round to even concept and I need the round to larger concept.

Rule One If the rounding digit is 4, 3, 2, or 1, drop all digits to the right of it.

Rule Two If the rounding digit is 5, 6, 7, 8, or 9 add one to the rounding digit and drop all digits to the right of it.

Is there a function in SmartBear to handle this requirement?