Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 13th, 2006, 03:32 PM
Registered User
 
Join Date: Apr 2006
Location: , , .
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 ?

  #2 (permalink)  
Old November 9th, 2006, 12:31 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:58 AM.


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