Wrox Programmer Forums
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 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 October 13th, 2006, 03:32 PM
Registered User
 
Join Date: Apr 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form reference ?

Hi all,
In VB6, I can reference the form as follow:
1. Call Display_Tip(Me, "This is tips ...")
2. Function Display_Tip(f as form, sTip as string)
     f!txtTips.text = sTip
   End function
3. So I can display_tip from any form that have txtTips text box
4. How can I do this in VS2005 ?

 
Old November 9th, 2006, 12:31 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Same way, more or less.

One way is to define an interface that exposes a method that "tip" code will use to communiate with the form. You would then replace the "form" parameter with a parameter of the interface, and call that method. In the form, the method is implemented to populate the text box with the tip message.

Another way is to declare a delegate, and define a method that uses the signature of the delegate on any form that you want to be able to inject a tip message. Then you would pass the delegate to your Display_Tip method and it would callback to that delegate for the message.

Another way is to have the tip code return the message and let the form to the work of populating the textbox.

Another way is to use reflection to find the textbox on the form. The form would have to passed as an object.

Another way is to loop through the controls collection of the passed in form and set the text on the one named txtTips

Another way is to merely pass the textbox control that you want to put the text into instead of the form.

Another way... there are probably at least 100 ways to do this.

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
reference. scandalous ASP.NET 2.0 Basics 1 April 9th, 2007 07:29 PM
Reference to parent form from child prashantha Visual Basic 2005 Basics 2 November 15th, 2006 03:54 PM
in need of reference! alialibidad SQL Language 1 June 4th, 2006 05:14 AM
form/subform reference tmc Access 1 August 7th, 2004 04:16 AM
Reference to another Windows form Controls Vince VB.NET 3 October 20th, 2003 09:42 AM





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