Delen via


Operands of type Object used for operator '<operatorsymbol>'; runtime errors could occur

An expression uses an operator for which one or both operands are of the Object Data Type.

When a variable or expression evaluates to Object, the compiler must perform late binding, which causes extra operations at run time. It also exposes your application to potential run-time errors. For example, suppose you assign a Form to an Object variable and then try to use it with the / Operator (Visual Basic). If you do this, the runtime throws an InvalidCastException because Visual Basic cannot convert a Form object to a numeric value.

By default, this message is a warning. For information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic.

Error ID: BC42019

To correct this error

  • If possible, arrange the operands to evaluate to data types for which the operator is defined.

See Also

Concepts

Arithmetic Operators in Visual Basic