Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Type Conversion Rules
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Type Conversion Rules
■ When necessary, Visual Basic converts a numeric constant from one type to
another, according to these rules:
If... Then...
════════════════════════════════════ ═══════════════════════════════
A numeric constant is assigned to a The numeric constant is stored
numeric variable of a different type as the type declared in the
variable name
A string variable is assigned to a The "Type mismatch" error
numeric value, or vice versa message is generated
A floating-point value is assigned The fractional portion is
to an integer rounded
■ Currency values are treated as floating-point numbers.
■ During expression evaluation, the operands in an arithmetic or relational
operation are converted to the same degree of precision (that of the most
precise operand) as each operation is performed. Also, the result of an
arithmetic operation is returned to the final degree of precision.
■ Logical operators such as AND and NOT convert their operands to long
integers if necessary. Operands must be in the range from -2,147,483,648
through 2,147,483,647, or Visual Basic generates the error message,
"Overflow." See: ◄Logical Operators►
See: ◄Basic Data Types Summary►