Home > Software > Appendices

Standard EXE Interacting with ActiveX EXE.dll

ActiveX .EXE : A Beginnerís Guide

6. Appendices:

Appendix A: Class Module

Appendix B: Form ActiveX

Appendix C: Standard Module

Appendix D: Standard EXE Form code

6.1 Appendix A:

Option Explicit

Public Function LoadForm(numbers_disp As Boolean, alphabets_disp As Boolean)

'Load the form
Load frmActivexEx
frmActivexEx.Caption = frmActivexEx.Caption
'make the controls on the form as disabled initailly
frmActivexEx.cboAlphabets.Enabled = False
frmActivexEx.cboNumbers.Enabled = False
'Based on the option user selected
'make its correspondins drop-down box enabled
If numbers_disp = True Then
     frmActivexEx.cboNumbers.Enabled = True
ElseIf alphabets_disp = True Then
     frmActivexEx.cboAlphabets.Enabled = True
End If

End Function

Private Sub Class_Initialize()

'selectedItem is a global variable declared in module
'set it to nothing initially
'whcih implies that no item has been selected
selectedItem = "Nothing"

End Sub

Private Sub Class_Terminate()

'on terminating unload the form
Unload frmActivexEx

End Sub

Public Function getselectedchar() As String

'function that gets the item selected in the drop-down box
getselectedchar = selectedItem

End Function

6.2 Appendix B

Option Explicit
Private Sub cboAlphabets_Click()

'assign the selectedItem variable
'to the item that is selected in the drop-down box
selectedItem = cboAlphabets.Text

End Sub

Private Sub cboNumbers_Click()

'assign the selectedItem variable
'to the item that is selected in the drop-down box
selectedItem = cboNumbers.Text

End Sub

Private Sub cmdSelAndClose_Click()

Unload Me

End Sub

6.3 Appendix C

Option Explicit
'global variable which stores the item
'selected in drop-down box
Public selectedItem As String

6.4 Appendix D

'variable of type clsActivexEx class in Activex_ex component
Dim actvixTest As clsActivexEx
Option Explicit
Private Sub cmdCallActivex_Click(

'create an object for class clsActivexEx in AxtivexEx component
Set actvixTest = New clsActivexEx
'call the LoadForm method
'and pass the values of both te option buttons
'which tells the option that the user has choosen
'and what drop-down box to enable
actvixTest.LoadForm optNumbers.Value, optAlphabets.Value

End Sub

Private Sub CmdShowSelVal_Click()

'function that gets the value selected in ActiveX Exe
'and dispalys in a message box
If actvixTest Is Nothing Then
     MsgBox "You have selected Nothing.", 64, "Selected Item in ActiveX Exe"
     MsgBox "You have selected " & actvixTest.getselectedchar & " in ActiveX Exe.", , "Selected Item in ActiveX Exe"
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

'on closing the form set the object actvixTest to point to nothing
'thereby removing reference the class clsActivexEx in component Activex_ex
Set actvixTest = Nothing

End Sub
Standard EXE Interacting with ActiveX EXE.dll

     Home                                                Copyright © 2003-2018 TutorialsWeb.com                                   Disclaimer                                           Sitemap