pass data with dialog result

Posted on 2009-02-18
Last Modified: 2013-11-26
How to pass data back from child form to main form using showdialog and dialog result.  I just know how to pass from main to child but not the other way around.  Please help!
Main Form:

Dim Frm as new form2

If frm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

<perform some task>

end if

frm = nothing

Child Form:

Me.DialogResult = System.Windows.Forms.DialogResult.OK

Open in new window

Question by:johnyu1997
    1 Comment
    LVL 85

    Accepted Solution

    You can access the elements on Form2 directly via your "frm" variable:

        If frm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            ' grab a value from a textbox for instance:
            Dim entry As String = frm.TextBox1.Text
        end if

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now