7.7. Notes on Declaring and Using Methods

There are three ways to call a method:

  1. Using a method name by itself to call another method of the same class or module—such as Maximum(number1, number2, number3) in line 56 of Fig. 7.4.

  2. Using a variable that contains a reference to an object, followed by a dot (.) and the method name to call a method of the referenced object—such as the method call in line 10 of Fig. 7.5, gradeBook1.DisplayGradeReport(), which calls a method of class GradeBook from the Main method of module GradeBookTest.

  3. Using the class or module name and a dot (.) to call a Shared method of a class or module (all methods of a module are implicitly Shared). One example of this is Math.Sqrt(900.0) in Section 7.5.

Note that a Shared method ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.