Return and parameter types of '<logicaloperator>' must be '<typename>' to be used in a '<shortcircuitoperator>' expression

An And operator or an Or operator is declared with unsuitable parameters or return type for use in an AndAlso Operator or an OrElse Operator.

Because you do not define a short-circuiting operator (AndAlso or OrElse) directly, you must define the corresponding logical and determinant operators. The following table shows the required operators.

Short-circuiting operator

Logical operator

Determinant operator

AndAlso

And Operator (Visual Basic)

IsFalse Operator

OrElse

Or Operator (Visual Basic)

IsTrue Operator

Visual Basic uses these logical and determinant operators to construct the short-circuiting logic for AndAlso or OrElse. For this to work properly, both operands and the return value of your And or Or definition must be of the containing type, that is, the type of the class or structure in which you are defining And or Or.

Error ID: BC33034

To correct this error

  • Change the type of both operands and the return value to the type of the class or structure in which you are defining this operator.

    -or-

  • Do not use the corresponding short-circuiting operator (AndAlso or OrElse) with operands of the type of the class or structure in which you are defining this And or Or operator.

See Also

Tasks

How to: Define an Operator

How to: Define a Conversion Operator

Concepts

Operator Procedures

Logical and Bitwise Operators in Visual Basic

Reference

Operator Statement