How to: Call an Operator Procedure (Visual Basic)
You call an operator procedure by using the operator symbol in an expression. In the case of a conversion operator, you call the CType Function (Visual Basic) to convert a value from one data type to another.
You do not call operator procedures explicitly. You just use the operator, or the CType function, in an assignment statement or an expression, the same way you ordinarily use an operator. Visual Basic makes the call to the operator procedure.
Defining an operator on a class or structure is also called overloading the operator.
To call an operator procedure
Use the operator symbol in an expression in the ordinary way.
Be sure the data types of the operands are appropriate for the operator, and in the correct order.
The operator contributes to the value of the expression as expected.
To call a conversion operator procedure
Use CType inside an expression.
Be sure the data types of the operands are appropriate for the conversion, and in the correct order.
CType calls the conversion operator procedure and returns the converted value.
The following example creates two TimeSpan structures, adds them together, and stores the result in a third TimeSpan structure. The TimeSpan structure defines operator procedures to overload several standard operators.
Because TimeSpan overloads the standard + operator, the previous example calls an operator procedure when it calculates the value of combinedSpan.
For an example of calling a conversation operator procedure, see How to: Use a Class that Defines Operators (Visual Basic).