Should be a simple question

Posted on 2006-04-26
Last Modified: 2010-04-23
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
Question by:dchau12
    LVL 7

    Accepted Solution

    frmName.mytextBox.Text = 2333
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    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.

    Author Comment

    Thanks for the input guys

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now