alexskinner
New Member
- Joined
- May 24, 2016
- Messages
- 9
I am testing one value as a multiple of another and suspect that they are stored differently.
I have a routine accumulating money values in various denominations.
There is a text box for each coin denomination ( eg 50 cent,20 cent, 10 cent etc) called tb10cents, tb20cents etc.
I wish to prevent users from entering 65 cents in the 20cent textbox (for example) .
My routine is:
Iftb20Cents.Value/0.2 <> Round(tb20cents.Value/2) then
Display an error message and return theuser to the input area
Else
Perform the required actions
Endif
This works well for some values but not for all. For example is the text box contains 0.60 (which is a multiple of 20 cents) the error message is displayed.
I suspect that it s because Excel treats numbers differentlybut don’t know how to overcome the problem.
I have tried If tb20Cents.Value Mod 2 <> 0 but thatproduces the same result.
Can anyone provide a solution and if possible the reasoningbehind the problem.
I have a routine accumulating money values in various denominations.
There is a text box for each coin denomination ( eg 50 cent,20 cent, 10 cent etc) called tb10cents, tb20cents etc.
I wish to prevent users from entering 65 cents in the 20cent textbox (for example) .
My routine is:
Iftb20Cents.Value/0.2 <> Round(tb20cents.Value/2) then
Display an error message and return theuser to the input area
Else
Perform the required actions
Endif
This works well for some values but not for all. For example is the text box contains 0.60 (which is a multiple of 20 cents) the error message is displayed.
I suspect that it s because Excel treats numbers differentlybut don’t know how to overcome the problem.
I have tried If tb20Cents.Value Mod 2 <> 0 but thatproduces the same result.
Can anyone provide a solution and if possible the reasoningbehind the problem.