CLASS                                                                  Statement

CLASS name

[statements]

END CLASS

Description

Declares the name of a class, as well as the variables, properties and methods in the class. Variables are defined as PUBLIC or PRIVATE. Properties are defined using PROPERTY SET, PROPERTY LET and PROPERTY GET code blocks. Methods are defined as SUB or FUNCTION blocks. Each class also has optional Class_Initialize and Class_Terminate subroutines that are called when a instance of the class is created or removed. Windows CE 4.0 or later only.

Example

Class cGreeter

  Public Sub SayHello(who)

    Print "Hello, " & who & ". Welcome to " & Store & "."

  End Sub

  Public Store

  Public Property Get StoreNumber

    Select Case Store

    Case "Main Branch": StoreNumber = 1

    Case "DownTown:": StoreNumber = 2

    End Select

  End Property

  Sub Class_initialize

    Store="Main Branch"

  End Sub

  Sub Class_terminate

    Print "Greeter terminated"

  End Sub

End Class

 

Dim p

Set p = new cGreeter

p.sayHello("Cartman")

Print p.StoreNumber

Set p=Nothing

Output

Hello Cartman. Welcome to Main Branch.

1

Greeter terminated

Related Items

DIM, FUNCTION, PROPERTY, SET, SUB, WITH