Calling Public Function from another form

Posted on 2004-11-24
Last Modified: 2010-04-23
I have 2 forms. One being a Search form and the other being the Data form.

The Search form is loaded from the Data form where the user conducts their search.

My problem is that after the user finds the particular record they're after and pick it up from the list I need to call a Public function in the data form to load all the data into the data form.

How can I call this function in the data form from the search form?
Question by:PeterErhard
    LVL 4

    Accepted Solution

    This code should do what you are looking for. I am assuming that for search form is named SearchForm and your data form is named DataForm.

    ---------SearchForm code

    Public dataForm as DataForm

    Private Function loadData()
          Return DataForm.getData()
    End Function

    ---------DataForm code

    Private Sub showSearchForm()
          Dim sForm as new SearchForm
          sForm.dataForm = me
    End Sub

    Public Function getData()
          'Code to get data and return it
    End Function

    Author Comment

    Thanks - that did the trick.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now