When I try this Code:
A = 19 Mod 6.7
the Result is 5 but it should be 5.6 Can someone say me, whats going wrong?
Annoyingly, VBA will round the 6.7
to 7
as it doesn't have a floating point modulus function (cf. Java).
Effectively it evaluates 19 Mod CInt(6.7)
, and CInt
uses German Rounding, rather than integer truncation.
If you want to duplicate the behaviour of the MOD function on a worksheet, see VBA equivalent to Excel's mod function
MOD is an integer function in VBA. It would be better to use:
a - (b * (a / b))