• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Should be a simple question

In a Microsoft Windows Application, how do you access the controls of a Form from a Module?  In VB6 the syntax to change the textbox on form "MyForm" from a module was something like: Form_FormName.mytextbox.Value = 2333.

Does anyone know the syntax for vb.net?
1 Solution
frmName.mytextBox.Text = 2333
Mike TomlinsonMiddle School Assistant TeacherCommented:
It depends on the version of VB.Net you have...

For VB.Net 2003 and below, you can't use the Forms name like you used to in VB6.  You must have a reference to the form you want to iterate over.  This means either passing into your sub/function in your module or by declaring a global public form variable in your module and then setting that global variable from your forms load event.

In VB.Net 2005, you can use the Forms name just like you did in VB6.  VB.Net 2005 also has a forms collection similar to VB6:
There is no OpenForms() collection in VB.Net 2003 and below (there is for MdiChildren but thats different).  If you want one there you have to track the open forms yourself in a your own collection such as the ArrayList.
dchau12Author Commented:
Thanks for the input guys

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now