A file with public symbols that are accessible by other modules/macros via the #Uses comment.
A module may also access other modules with its own #Uses comments.
Group: Declaration
Description: A class module implements an ActiveX Automation object.
Has a set of Public procedures accessible from other macros and modules.
These public symbols are accessed via an object variable.
Public Consts, Types, arrays, fixed length strings are not allowed.
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
'A.WWB
'#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
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
Group: Declaration
Description: A Code module implements a code library.
Has a set of Public procedures accessible from other macros and modules.
The public symbols are accessed directly.
'A.WWB
'#Uses "Module1.BAS"
Sub Main
Debug.Print Value '"Hello"
End Sub
'Module1.BAS
'File|New Module|Code Module
'Edit|Properties|Name=Module1
Option Explicit
Private mValue As String
Property Get Value() As String
Value = mValue
End Property
'this sub is called when the module is first loaded
Private Sub Main
mValue = "Hello"
End Sub
Group: Declaration
Description: An object module implements an ActiveX Automation object.
It has a set of Public procedures accessible from other macros and modules.
These public symbols are accessed via the name of the object module or an object variable.
Public Consts, Types, arrays, fixed length strings are not allowed.
An object module is similar to a class module except that one instance is automatically created. That instance has the same name as the object module's name.
To create additional instances use:
Dim Obj As objectname
Set Obj = New objectname
'A.WWB
'#Uses "System.OBM"
Sub Main
Debug.Print Hex(System.Version)
End Sub
'System.OBM
'File|New Module|Object Module
'Edit|Properties|Name=System
Option Explicit
Declare Function GetVersion16 Lib "Kernel" _
Alias "GetVersion" () As Long
Declare Function GetVersion32 Lib "Kernel32" _
Alias "GetVersion" () As Long
Public Function Version() As Long
If Win16 Then
Version = GetVersion16
Else
Version = GetVersion32
End If
End Function