Quote:
Originally Posted by grvinton
The following code is used similarly in a more complex program. The user will input the number of clicks, the factor and the total. The program calculates the clicks times the factor and compares the result to the input total. Various numbers produce an unequal comparison despite the fact that both numbers are the same. What am I doing wrong?
Option Explicit
dim intClicks
dim dbltotlbs
dim dblfactor
dim dblpounds
dblfactor = 0.33
intclicks = 3948
dblpounds = 1302.84
dbltotlbs = intclicks * dblfactor
if dbltotlbs <> dblpounds then
MsgBox dbltotlbs
MsgBox dblpounds
else
MsgBox "Equal"
end if
MsgBox "end"
................
Using 3949 and 1303.17 checks out ok. There are other combinations that work and still others that don't.
Thanks in advance for any light you can shed on the problem.
Hi -
You may try to round it off and specify the digits after decimal.