Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2006, 08:26 AM
Authorized User
 
Join Date: Dec 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Best way to return value from form?

What's the best way to return a value to a class from a form ... for example, a class calls a form to display a text box and the user's input value needs to be returned to the class. I've used global variables in VB6, but they're inelegant!

 
Old December 14th, 2006, 10:47 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

The code using it can peek at the form's public variables and that includes the controls. So you can do something like this:

    Dim frm As New GetDataForm
    frm.ShowDialog()
    Debug.WriteLine(frm.txtFirstName.Text)
    Debug.WriteLine(frm.txtLastName.Text)

You can also set the form's DialogResult property to let the calling code know if the user clicked OK or Cancel.

Take a look at pages 302-303.


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
need some help please getting a return value merk ASP.NET 2.0 Basics 4 October 3rd, 2007 07:10 PM
ModalDialog form unable to return value to webpart singhmanpreet ASP.NET 2.0 Professional 0 May 21st, 2007 06:35 PM
"Return parameters" on a form carlf01 BOOK: Expert One-on-One Access Application Development 0 March 2nd, 2007 07:35 PM
return type? Sibananda Tripathy J2EE 1 January 3rd, 2005 04:03 AM
Form validation & conditional return confirmation GMiles1972 Javascript How-To 3 February 3rd, 2004 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.