VB Classes

VB Classes

Classes are defined in VB.NET using a separate VB code file.  The code file name is the same as the class name.

In VB.NET the class attributes are defined within the class definition as variables.

The class methods are defined within the class definition as Subs and Functions.

Class properties allow objects to access their attributes.

In this example the class Animal contains two attributes: name and greeting.  The class' Property provides Get and Set operations to access (Get) and assign (Set) attributes.

The New procedure defines how new objects of that class are created.  The MyBase.New() statement directs VB.NET to use the base Object constructor.

                       

posted @ 2015-06-17 00:07  xymum  阅读(167)  评论(0编辑  收藏  举报