Solved

Share controls between classes

Posted on 2009-05-05
3
200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

11 Experts available now in Live!

Get 1:1 Help Now