Link to home
Create AccountLog in
Avatar of ddepuemd
ddepuemd

asked on

Share controls between classes

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?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You would either pass a REFERENCE to the Form or the actual Control INTO your class and store their internally for use...
Avatar of ddepuemd
ddepuemd

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer