Solved

Share controls between classes

Posted on 2009-05-05
3
199 Views
Last Modified: 2012-05-06
I have a form in vb.net and want to include some classes outside the form class to perform some functions.  Is it possible to use the controls on the form, say a textbox, in the separate class without having to duplicate the value prior to calling the class function?  How do you address the controls directly  from a different class?
0
Comment
Question by:ddepuemd
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24308232
You would either pass a REFERENCE to the Form or the actual Control INTO your class and store their internally for use...
0
 

Author Comment

by:ddepuemd
ID: 24308743
Here's what I have done - I had a sub that examined several controls for legal values then wrote out a record to a database to save it.  I copied the sub to a new class and simply referenced the controls to the form as:

Form1.TextBox

This seems to work fine!
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24308853
Ok...that works because Form1 is the "Startup Object" for your application and you are actually accessing the "default instance" of the form (created for you when the app started).  If you were not dealing with the default instance the a REFERENCE to the desired form would have to be passed into your Sub....
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

14 Experts available now in Live!

Get 1:1 Help Now