CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 1999
    Posts
    1

    To All CODE GURUS: How to access a subroutine or function from another form



    Hi,

    I have a usercontrol and a form in project. I want to access some functions or subroutines of UserControl from the Form.

    I can do the reverse. ie. call a form's method from a usercontrol. example: Form1.Method.



    BUT THIS DOESN'T WORK IN A FORM. Example: UserControl.Method.


    Please help me, since I need to do some action based on some events occured in the form.

    Any ideas would be of great help.


    Thanks,


    Vinod

  2. #2
    Join Date
    May 1999
    Posts
    45

    Re: To All CODE GURUS: How to access a subroutine or function from another form



    If your methods are public you should be able to access the methods. I am assuming you are calling a method of an instance of user control.


    Dim myctl as MyUserControl

    Set myctl = new MyUserControl

    myctl.Method


    should work...


    You can't call

    MyUserControl.Method

    for two reasons,


    1) VB does't support class methods.

    2) Unlike forms, VB won't create global instance of your user control.

    In case of forms it creates hidden global object of the form class.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured