Class Statement

This statement begins a Class definition.

[ Public | Private ] Classclass_name

Prerequisites

A Class may only be declared at the top level of a file, within a Module, or within another Class.

Parameters

class_name

The name of the Class being defined.

Remarks

A Class definition must always end with an End Class statement. If a Class is declared Public, it can be accessed from outside the Module or Class in which it is defined. A PrivateClass can only be accessed within the Module or Class where it is defined. If the Public attribute is omitted, the Class defaults to Private. Other attributes such as Friend or Protected are not supported. Variables, constants, and procedures defined within the Class are members of the Class and can only be accessed by first specifying the Class or an object of the Class.

Examples

Public Class cc           ' Begin the class
Public x As Single ' Variable x is in cc object
Public y As Single ' Variable y is in cc object
End Class

Sub test
Dim obj As New cc ' Create object of class cc
obj.x = 2.5 ' Set x value in new object
End Sub

See Also

Statements |ModuleStatement