ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format of textbox on userform and correct result (https://www.excelbanter.com/excel-programming/303900-format-textbox-userform-correct-result.html)

mark

Format of textbox on userform and correct result
 
I amusing Excel 97.

I am trying without much look to calculate the VAT and
have used the following.

txtVAT1.Value = Format((Val(txtT1.Value) + Val
(txtNT1.Value)) * (Val(txtT1.Value) + Val
(txtNT1.Value)) / 17.5, "£##.00")

Firstly, when I use the above formula and say the value
of txtT1 is £9 and the value of txtNT1 is £1 the sum is
£10 and the VAT amount is correctly calulated to £1.75.

However if I changes to values to £90 & £10 respectively
then the result of the VAT is £175!!

Secondly, how do you force the txtbox to only 2 decimal
places I have tried the above and it's very hit and miss.

The whole problem is obviously to do with decimal spaces
but I'm stuck any takers?

Regards

Mark

Peter T[_3_]

Format of textbox on userform and correct result
 
Hi Mark

Is this what you want:

Sub egFormat()
x = 1.234567 * 12345.678
y = Format(x, "£#,##0.00")
MsgBox y & vbCr & vbCr & x
End Sub

Regards,
Peter


-----Original Message-----
I amusing Excel 97.

I am trying without much look to calculate the VAT and
have used the following.

txtVAT1.Value = Format((Val(txtT1.Value) + Val
(txtNT1.Value)) * (Val(txtT1.Value) + Val
(txtNT1.Value)) / 17.5, "£##.00")

Firstly, when I use the above formula and say the value
of txtT1 is £9 and the value of txtNT1 is £1 the sum is
£10 and the VAT amount is correctly calulated to £1.75.

However if I changes to values to £90 & £10 respectively
then the result of the VAT is £175!!

Secondly, how do you force the txtbox to only 2 decimal
places I have tried the above and it's very hit and miss.

The whole problem is obviously to do with decimal spaces
but I'm stuck any takers?

Regards

Mark
.



All times are GMT +1. The time now is 02:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com