Part IV. Classes

The lessons in Section III focus on Visual Basic programming statements. They explain how to make decisions with If and Select Case statements, repeat program steps with loops, reuse code with procedures, and catch exceptions.

Procedures are particularly useful for programming at a higher level because they let you encapsulate complex behaviors in a tightly wrapped package. For example, you might write a CalculateGrade function that determines a student's grades. This method can hide all the details about how grades are calculated. (Are tests graded on a curve? Is the grade a weighted average of tests and homework assignments? How much is attendance worth?) The main program only needs to know how to call the function, not how it works.

Classes provide another even more powerful method for abstracting complex entities into manageable packages. For example, a Student class might embody the idea of a student and include basic information (name, address, phone number), the courses that the student is taking, grades (test scores, homework grades), and even attendance. It would also include methods such as CalculateGrade for manipulating the Student data.

The lessons in this section explain classes. They explain how you can build classes, make one class inherit the capabilities of another, and make a class override the features of its parent class.

Get Stephens' Visual Basic® Programming 24-Hour Trainer 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.