O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Operators

Now that you’ve seen the background information, you can go on to implement some static operator procedures. You’ll use standard math calculation operators in this example.

The example here differentiates between two types: actual operators, such as +, –, *, /, and so on, and operators that are used to convert types. You’ll start with the calculation operators:

Public [Class|Structure] OpType
    Public Shared Operator OpChar(ByVal objVar1 As [OpType|Type1], ByVal objVar2 As
[OpType|Type2]) As Type3
        ' Here is the code that performs the actual operation
    End Operator
End [Class|Structure]

The code body illustrates what’s important:

  • You can apply operators to classes and structures.

  • Which operator (+,–, *, /, and so on) is used is specified ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required