H
Howard
Hi,
I'd like to validate two numbers being entered on a form.
One is to within 0.5 ( i..e. 6.5 or 7.0 is ok but 6.6 and 6.4 are not.)
and the other is to within 0.05 (i.e 6.05 and 6.40 are OK but 6.47 and 6.52
are not
I seem to be able to do the first one using
if (n - int(n) <> 0 ) and (n- int(n) <> 0.5) then msgbox "invalid"
but when I try almost the same thing with the second number using
if (n - int(n) <> 0 ) and (n- int(n) <> 0.05) then msgbox "invalid"
it fails.
The reason is that when n = 6.05 (i.e. a valid number), the value of n -
int(n) is held as 0.0499999999999 and so does not = 0.05.
what is the best way to get round this?
Howard
I'd like to validate two numbers being entered on a form.
One is to within 0.5 ( i..e. 6.5 or 7.0 is ok but 6.6 and 6.4 are not.)
and the other is to within 0.05 (i.e 6.05 and 6.40 are OK but 6.47 and 6.52
are not
I seem to be able to do the first one using
if (n - int(n) <> 0 ) and (n- int(n) <> 0.5) then msgbox "invalid"
but when I try almost the same thing with the second number using
if (n - int(n) <> 0 ) and (n- int(n) <> 0.05) then msgbox "invalid"
it fails.
The reason is that when n = 6.05 (i.e. a valid number), the value of n -
int(n) is held as 0.0499999999999 and so does not = 0.05.
what is the best way to get round this?
Howard