O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

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

Using Methods

Class methods can be used as you would use any function or subroutine, except that you need a valid object on which to invoke the method. Use the dot-notation to invoke the method and place the parameters (if any) in parentheses after the method name. If the method is a function, you can assign the result value to a variable of the appropriate type or use the function in an expression.

You have probably noticed that the properties and methods are relatively similar from the implementation point of view. For example you could easily rewrite the Horse class presented previously to replace all properties with functions and subroutines, as shown in the example:

 Public Class Horse Private m_name As String Private m_color As String Private ...

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