Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can a component reference a form on the calling App?
Message
 
To
09/10/2001 06:38:28
General information
Forum:
Visual Basic
Category:
COM, DCOM and OLE automation
Miscellaneous
Thread ID:
00565840
Message ID:
00565841
Views:
20
>I have a function that prints the details of a form using a revised method of PrintForm. I want to be able to put this into our standard Utilities module. However, I do not know how to pass a reference to this form across to the component.
>
>So, I want a button on a form to call the function as.....
>
> call SuperPrintForm(me)
>
>and the function to do something like....
>
> Public Function SuperPrintForm(theform as Form)
> msgbox "This routine was called by " & theform.name
> end Function
>
>This will work fine with the function being part of the application. But when it is stored in another component (ActiveX DLL), the FORM as a datatype is not permitted.
>
>Can anyone tell me how to get around this please?


From an OCX, you can easily call a public method:

In the UserControl:
Private Sub Text1_Change()
    'CallByName UserControl.Extender.Parent, "ValidateForm", VbMethod, UserControl.Extender.Name
    UserControl.Extender.Parent.ValidateForm UserControl.Extender.Name
End Sub

On the Form:
Public Sub ValidateForm(ByVal pstrControlName As String)
    MsgBox "Validation asked for control " & pstrControlName
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform