O'Reilly logo

Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition by Harvey M. Deitel - Deitel & Associates, Inc., Paul J. Deitel - Deitel & Associates, Inc.

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

4.8. Validating Data with Set Accessors in Properties

In Section 4.5, we introduced properties whose Set accessors allow clients of a class to modify the value of a Private instance variable. In Fig. 4.7, class GradeBook defines property CourseName’s Set accessor to assign the value received in its parameter value to instance variable courseNameValue (line 14). This CourseName property does not ensure that courseNameValue contains valid data. In this section, we enhance our property to include data validation in its Set accessor. Property CourseName (Fig. 4.12) does not ensure that the course name adheres to any particular format or follows any other rules regarding what a “valid” course name is. Suppose that a university can display student ...

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