ReferACTXProp




Public YourProperty As String
Public Sub ShowMainForm()
'passes control reference to form

Load frmMain
Call frmMain.ControlRef(Me)
frmMain.Show
End Sub

'4. This will create one method (ShowMainForm)

' and one property (YourProperty) for your

' user control.

'5. Add the following code to the the form (frmMain):

' Holds reference to usercontrol Private cCtl As ctlTest

' Takes control reference passed and stores in in local

' variable

Public Sub ControlRef(cC As ctlTest)
Set cCtl = cC
End Sub

Private Sub cmdMain_Click()
cCtl.YourProperty = _
"Changing Property Value From Another Form!"
End Sub

'6. Please note that any changes to properties of the user

' control or calls to methods or proceedures must occur

' on or after the Form_Activate event.

'7. From whatever project you add your new user control to,

' you can now use the ShowMainForm method to open the

' main form and pass the control reference, and manipulate

' the properties of the control.

Steps:
1. Create an ActoveX Control Project and name it ctlTest.
2. Add a form to the project and name it frmMain
3. Add a command button to the Form and name it cmdMain
3. Add the following code to the user control:










( referactxprop.html )- by Paolo Puglisi - Modifica del 17/12/2023