Format of textbox on userform and correct result

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

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
 
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
 
Back
Top