Click to See Complete Forum and Search --> : Property on UserControl


atreis
September 19th, 2001, 04:42 PM
Hi, guys !
I have an ActiveX control with a single Usercontrol that have a button calling a Form.
In that form, I want to set an property on UserControl, but I dontīt know how to do it !
How can I refer the user control in the form ?
How can I do that form to set a property on UserControl ?...

DSJ
September 19th, 2001, 04:55 PM
One way is to give the form your calling a property which contains a reference to the usercontrol so your button click might look like:



private Sub Button_Click()
set form1.ownercontrol = usercontrol
form1.show
end sub





then your form could reference it like:


me.ownercontrol.(whateveryouneedtodohere....)

michi
September 19th, 2001, 05:05 PM
Hi,

I did a smiple test as following. The property on the UserControl is TestName, and I can refer it on the test form.

============
'in the Active Control form

Option Explicit
Private mstrName As String

Private Sub Command1_Click()
MsgBox "Hello"
End Sub

Public Property Let TestName(strName As String)

mstrName = strName

End Property


Public Property Get TestName() As String

TestName = mstrName

End Property

===
'In the test from

Private Sub Form_Load()
UserControl11.TestName = "aaa"
End Sub

=======

Regards,

Michi