Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a ActiveX public sub in the Control from a form

Status
Not open for further replies.

bilgner

Programmer
Sep 10, 2004
4
ZA
How can one access a public sub in an activeX control from a form ? The form is started from the control(called shapeCtl) with form1.show 0

The shapeCTL has a public function defined as

Public property let Caption( ByVal Newcaption as string)
msgbox Newcaption
end sub

I would expect to at least be able to use something like shapeCtl.caption = "xxx" in my form1 but the shapeCTL does not even appear with Intellisense.

Thanks
 
I think that you are getting confused on what a function, a sub and a property are since you've used them interchangeably to describe one thing.

I am assuming that your active x control resides in a separate project from your form. If so, the value in your property will not be accesible at control run-time. I had a similar problem to what you have and this is how I worked around it.

Create a module to hold global variables and declare a global variable called glbCaption. Add this module to your active x control project.

Within your active x control's module, and in your let property, you need to assign a value to the caption property of the label, therefore you do like so,

Public property let Caption( ByVal Newcaption as string)
Label1.Caption = Newcaption
end sub

In your form open sub, do the following;

glbCaption = Label1.Caption
form1.show

Place a command button on form1 and then add then following code in its click event:

msgbox glbCaption

On form1 unload event, add the following code

glbCaption = ""

Let me know if this doesn't work.

 
Thank you very much for your assistance. In the end I reverted to raising an event in the .ocx from within the child form

In the .ocx:

Private WithEvents m_frmCallBack As EditImag
' where EditImage is the form

Private Sub m_frmCallBack_QuitCallBack()
cmdSave_Click
edit_unlock
End Sub


In the child form EditImag

Event QuitCallBack()

' and when I want to call the event
RaiseEvent QuitCallBack

This works very well

Other variables are made public in a .bas

I found the info in this newsgroup and on the msdn.microsoft.com which has good examples.

Thanks again.
bob


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top