First off, this explains the language change itself. Secondly addressing the point about the ms-help
link.
There is an explanation given on https://www.vbmigration.com/documentation/chapter3.aspx:
Mod operator
The VB6’s Mod operator automatically converts its operands to integer values and returns the remainder of integer
division:
Dim d As Double, i As Integer
d = 1.8: i = 11
Debug.Print i Mod d ' Displays 1, because it rounds up 1.8 to 2
VB.NET and C# don’t convert to Integer and return the remainder of
floating-point division if any of the two operands is of type Single
or Double.
That same page goes on to suggestion that by adding a CInt()
call you can reproduce the original behavior, such as:
Debug.WriteLine(i Mod CInt(d))
This is corroborated by official VB documentation.
VB6:
Remarks
The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result.
(actually the VBA docs...)
VB.Net:
Remarks
If either number1 or number2 is a floating-point value, the floating-point remainder of the division is returned. The data
type of the result is the smallest data type that can hold all
possible values that result from division with the data types of
number1 and number2.
Note that the ms-help
links would actually work if you still have VS2008 installed. It brings up the built in local help GUI. Not sure when these links stopped working, but I think by at least VS2015 they did not.
For this particular warning about Mod
the help system had this to say:
Mod Operator
In Visual Basic 6.0, the Mod
operator accepted any numeric expression
and the result was always returned as an integer.
In Visual Basic 2008, the Mod
operator no longer accepts variants, and
if either operand is a floating-point number, the result will be a
floating-point number.
IMHO this is NOT actually a very precise description of what is different. In particular, it does not sufficiently emphasize that the division result has been changed from always performing integer division. It only mentions about the return result being an integer.
The information above is more thorough.
For completeness, it also added:
What to do next
If a variant has been converted to an object during upgrade, convert it to the appropriate numeric data type.
If either of the operands is a floating-point number, modify the data
type of the result, or modify your code to convert the operand(s)
using the CShort
function before using the Mod operator.