Decimal places in vb6

August 25, 2005 at 06:42:41
Specs: win Xp sp2, 512

Please can someone help me, i need to get the value of AT to two decimal places instead of four thanks ant,ps.. these are all
currency variables

amt2 = CCur(Text29.Text)
vat = 1.14
AT = amt2 / vat
Text30.Text = AT


See More: Decimal places in vb6

Report •


#1
August 25, 2005 at 11:06:22

AT = format(AT,"#0.00")

The zeros ensure that something is printed even if the value is Zero.

AT = 4.2 with produce 4.20

AT = 34.347 with produce 34.35
Format rounds up the the next number.

at = 0 will produce 0.00

You can do the same with the Round function but that ignores trailing zeros.

Stuart


Report •

#2
August 25, 2005 at 22:47:17

A note of caution.

If these rounded values are to be used in subsequent calculations please correct the variables from which they are derived.

If these numbers appear in a financial statement or spreadsheet, can you testify to the accuracy of your work.

As a long time auditor of financial statements and spreadsheets. I have found errors in other peoples work that involved 10's of millions of dollars. It gets very embarassing if you have to retract you work in court or to the SEC. It might cost your company a lot.



Report •

Related Solutions


Ask Question