Sample Code 12
Class CMain.
'Class CMain
'This class is a wrapper to the main form used by the application
'it only exposes the necessary properties, methods and events, all other
'form events not exposed by the class are handled directly by the
'main form
Option Explicit
'Private reference to the form wrapped by this class
Private WithEvents TheForm As FormMain
'Events fired by this class
Public Event OnQuit(Cancel As Integer)
Public Event OnLogTableClick()
Public Event OnFactorialTableClick()
Public Event OnAboutBoxClick()
Public Event OnExcelChartClick()
Private Sub Class_Initialize()
Set TheForm = New FormMain
End Sub
Private Sub Class_Terminate()
Unload TheForm
Set TheForm = Nothing
End Sub
Public Sub Show()
TheForm.Show
End Sub
Public Sub Hide()
TheForm.Hide
End Sub
'This property exposes to the outside the
'MSFlexGrid ActiveX control included in the form
Public Property Get fgTable() As Object
Set fgTable = TheForm.MSFlexGrid1
End Property
Private Sub TheForm_OnAboutBoxClick()
RaiseEvent OnAboutBoxClick
End Sub
Private Sub TheForm_OnExcelChartClick()
RaiseEvent OnExcelChartClick
End Sub
Private Sub TheForm_OnExitClick(Cancel As Integer)
RaiseEvent OnQuit(Cancel)
End Sub
Private Sub TheForm_OnFactorialTableClick()
RaiseEvent OnFactorialTableClick
End Sub
Private Sub TheForm_OnLogTableClick()
RaiseEvent OnLogTableClick
End Sub