We help IT Professionals succeed at work.
Get Started

vb.net: How do you use textbox.text as string variable in another class?

Last Modified: 2013-12-26
Experts, this should be an easy one...I have a textbox on a form and need help figuring out how to use its  .text value in another form's code page (is that a class?).  For example there's a form with the textbox "NameTB" therefore the user input value would be captured in the Me.NameTB.text for that form.  However I need to use the value from Me.NameTB.text in code associated with another form (a separate class)...how do you do that?  I thought I could just do this: (but I got an error saying textbox cannot be converted to string)

Public NameTBtwo as string
NameTBtwo = Me.NameTB.text

...then use the "NameTBtwo" variable in the code associated with another form, but it doesn't work.

Any help is greatly appreciated...thank you!!!!!!!
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE