CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    26

    Access to Form from Main

    Hi

    I have written a VB program that starts from Sub Main. Sub Main is in a Module and Also I have a form in my project.

    How can I access to my form and it's controls from Sub Main

    Thanks


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Access to Form from Main

    You can reference a form directly by name i.e. if your form is called "Form1" and has a textbox "txtName" rthen the following is perfectly valid in code:

    Debug.print Form1.txtName.Text




    Note that your VB form is also a template for the creation of forms of the same type i.e.:

    Dim frmThis as Form1

    set frmThis = new Form1
    Debug.print frmThis.txtName.Text




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured