I believe the problem is actually two-fold. One is floating point error, making the result of the multiplication slightly off. The other is banker's rounding.
Try it like this, and the two give the same answer:
This demonstrates banker's rounding.Code:Private Sub Command1_Click() Dim TotVal As Currency Dim VatRate As String VatRate = "15" TotVal = 3.1 MsgBox "Total VAT = " & ((TotVal * Val(VatRate)) + 0.5) / 100 MsgBox "Total VAT = " & Int((TotVal * Val(VatRate)) + 0.5) / 100 End Sub
The FormatNumber() function does not use banker's rounding, but if you're dealing with financial data, that may not be appropriate. The Currency data type would be the way to go, along with using only numeric data types in mathematical formulas.