Very Simple Variable Reference Question

  • Thread starter Thread starter jm
  • Start date Start date
J

jm

I have one form. It is named Form1.

I have one class file named netclass.cs

The form Form1 has one textbox named textBox1.

All I want to do is reference textBox1.text in the netclass.cs file.
I do not know how to do it and cannot find it by searching on Google.

Thank you.

I have tried

Form1 f as new Form1();
f.but nothing populates.

Thank you again.
 
jm said:
I have one form. It is named Form1.

I have one class file named netclass.cs

The form Form1 has one textbox named textBox1.

All I want to do is reference textBox1.text in the netclass.cs file.
I do not know how to do it and cannot find it by searching on Google.

Thank you.

I have tried

Form1 f as new Form1();
f.but nothing populates.

You need:

Form1 f = new Form1();

But you can't just create a new object and hope it's the right one -
you need to make sure the one you're using is the one you're also
displaying.

Basically, there's nothing special about forms here - you just get a
reference to it the same way you would for any other class.
 
Back
Top