Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

Calculation error in VBA?

$
0
0
I have been working with this error in vba, and it is driving me nuts. Look at the following code:

Code:

Sub testCalc()
    Dim temp1 As Double
    Dim temp2 As Double
    Dim temp3 As Double
    Dim temp4 As Double
   
    temp1 = 1415.5
    temp2 = 1492.7
    temp3 = 250
    temp4 = -5
   
    Debug.Print (temp1 - temp2) * temp3 * temp4
End Sub

It prints 96500,0000000001 (European dec separator , is used)

Where does the decimals come from - the correct result is only 96500

Viewing all articles
Browse latest Browse all 50090

Trending Articles