Easy one - controls on forms

  • Thread starter Thread starter Helen
  • Start date Start date
H

Helen

I'm sure this is blindingly obvious, but after searching
through the so-called Help, I can't see how to do it.

How do I refer to a control on a form from another
module. For example, I want to set the text property of
text box txtText on form frmForm.

I've tried:
frmForm.txtText.Text = "Data"
as in previous VB and it gives an error.

Thanks
 
Helen,

You would need to make the control on your form a public property... or use
a public property to set it.
Sorry this is a c# example.. I avoid VB like the plague for historical
reasons.

///In form class
TextBox myTextBox

public TextBox theTextBox
{
get
{
return myTextBox;
}
}

//or

public string TextBoxText
{
get
{
return myTextBox.Text;
}
set
{
myTextBox.Text = value;
}
}

Hope that helps

rollasoc
 
Back
Top