Class definitions

A class definition is the implementation of object oriented structures within the HBasic language. A class definition may define the following substructures that can be used local to a class instance:
<class-declaration> ::=
Class <classname> <class-body> End Class

<classname> ::= identifier

Create new class
You can create a new class instance with the <New-statement>.

Example: Define class c1 and create Instance of it


Class c1
... Definition of methods, properties ...
End Class

' create global instance of class c

Dim gc As c

Sub button1_clicked()
gc = New c()
End Sub


<class-body> ::= { <class-statement> }

<class-statement> ::=
<dim-statement> |
<event-declaration> |
<property-declaration> |
<sub-declaration>

Example: ex_classes

<Property declaration> ::=
Property identifier As <typedesc>
[ <Get-property-desc> ]
[ <Let-property-desc> ]
End Property

<Get-Property-desc> ::=
Get
<statementlist>
End Get

< Let-Property-desc> ::=
Let
<statementlist>
End Let

<Event declaration> ::= Event identifier ( <parameterlist> )

<Raise-statement> ::= Raise event-name( <expr-list> )

where event-name is the name of an event that has been defined in an <Event declaration>. The <Raise-statement> may only be used within the Class description which means in a method between Class ... End Class.

AltStyle によって変換されたページ (->オリジナル) /