Modules

Module Definition

A file with public symbols that are accessible by other modules/macros via the #Uses comment.

Class Module

Group: Declaration

Description: A class module implements an ActiveX Automation object.

Dim Obj As classname

Set Obj = New classname

Example

'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

Code Module

Group: Declaration

Description: A Code module implements a code library.

Example

'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

Object Module

Group: Declaration

Description: An object module implements an ActiveX Automation object.

Dim Obj As objectname

Set Obj = New objectname

Example

'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