Class Module
Group
DeclarationDescription
A class module implements an object.See Also
- Has a set of Publicprocedures accessible from other macros and modules.
- These public symbols are accessed by way of an object variable.
- Has an optional set of Events that can be raised.
- Public Consts, Types, arrays, fixed length strings are not allowed.
- Has an optional Private Sub Class_Initialize which is called when an instance is created.
- Has an optional Private Sub Class_Terminate which is called when an instance is destroyed.
- A class module is similar to a object module except that no instance is automatically created.
- To create an instance use:
Dim Obj As classname Set Obj = New classname
Code Module, Object Module, Uses, Class_Initialize, Class_Terminate
'A.WWB '#Language "WWB-COM" '#Uses "File.CLS" Sub Main Dim File As New File File.Attach "C:\AUTOEXEC.BAT" Debug.Print File.ReadLine End Sub 'File.CLS 'File|New Module|Class Module 'Edit|Properties|Name=File '#Language "WWB-COM" Option Explicit Dim FN As Integer Public Sub Attach(FileName As String) FN = FreeFile Open FileName For Input As #FN End Sub Public Sub Detach() If FN <> 0 Then Close #FN FN = 0 End Sub Public Function ReadLine() As String Line Input '#'FN, ReadLine End Function Private Sub Class_Initialize() Debug.Print "Class_Initialize" End Sub Private Sub Class_Terminate() Debug.Print "Class_Terminate" Detach End Sub