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

Class Methods with Sub and Function

Class code isn’t executed only in property procedures. Methods defined in Visual Basic by Sub or Function are also a part of the class. Non-static methods (those not defined via the class instance. see the section Static Methods, later in this chapter) are methods that should act upon the field variables of a class.

As an example, consider that a function, such as ContactText, could take care of returning the text representative of the class field values; the corresponding routines would look as follows:

Public Function ContactText() As String

    Return LastName & ", " & FirstName & ", " & _
            Zip & ", " & City

End Function

This member method of the class uses the instance variable directly and returns all its fields ...

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