Results 1 to 6 of 6

Thread: *Resolved*What we used to do in VB6, to show a form?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    *Resolved*What we used to do in VB6, to show a form?

    form2.show

    now if I have say a button(toolbar) and a menu item which calls his same form? on the clicks event - I just call formname.show. Thats it.

    Come VB.NET

    To display a form we use:

    dim frm as new form2
    frm.show

    Prob: Now if some one clicks on the button twice or say once on the button and then in the menu item - then as many instances of form2 are created and displayed - how do I STOPPPPP this?
    Last edited by veryjonny; Aug 9th, 2002 at 12:59 AM.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    Dont declare the new form there! You could declare your forms in a module instead!

    Code:
    Public Module TestModule
    
               Public frm as new Form2
    
    End Module
    
    
    Public Class Form1
    
         Public Sub LoadForm2
    
               frm.Show
    
         End Sub
    
    End Class
    I don't understand why so many people have trouble with this. I'm also a newbie at VB.NET (finnished my book just a couple of weeks ago).

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Me too a newbie.
    But doesnt declaring the way u suggest load the form in memory even before I need it?

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well if you dont need to access the form in the module then just do it all at once:

    dim frm as new form2
    frm.show

  5. #5
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261

    Re: hi

    Originally posted by veryjonny
    Me too a newbie.
    But doesnt declaring the way u suggest load the form in memory even before I need it?
    I guess, but so what?

    If you really need to, you could always check if the form has been loaded already.

    Code:
    Public Class Form1
    
         Dim frm As Form2
    
         Public Sub ShowForm
        
              If frm Is Nothing Then
              
                   frm = new Form2();
             
              End If
    
              frm.Show
    
          End Sub
    
    End Class

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    yes. Thats what I was missing.

    thanks

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