4.3. Declaring a Class with a Method and Instantiating an Object of a Class

We begin with an example that consists of class GradeBook (Fig. 4.1) and module GradeBookTest (Fig. 4.2). Class GradeBook (declared in file GradeBook.vb) displays a message on the screen (Fig. 4.2) welcoming the instructor to the grade-book application. Module GradeBookTest (declared in file GradeBookTest.vb) contains the Main method that instantiates (creates) and uses an object of class GradeBook. The class and module are placed in separate files for clarity, but it is possible to place them in the same file.

Figure 4.1. Class declaration with one method.
					' Fig. 4.1: GradeBook.vb
					' Class declaration with one method.
					Public Class GradeBook
					' display a welcome ...

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.