Results 1 to 3 of 3

Thread: Question on creating new forms

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    181

    Question on creating new forms

    hey. In my program I have a button set to make new form appear. The code is as follows:

    If fu Is Nothing Then
    fu = New FormUpdate
    End If

    fu.ShowDialog()

    fu is in a module by the way. The thing is that whenever I close the formFu, and reopen it with the button, all the variables are the same. They have the same information from opening it before. This makes me think that its not fully getting rid of it each time I close it. Is there some code I can put in fu to make it so that it completely removes it, and then each time I click the button it would be forced to make a new one of it, and I wouldnt have to manually reset all the variables? Is this the right way to approach this?

    Thanks
    John

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: Question on creating new forms

    If you declare the form as WithEvents, you can add the following to your closed event:

    fu.dispose()
    fu = nothing

    I don't know what scope the form is, so I'm not sure if this is an option or not. Either way, after adding those two lines, the "is nothing" will return true each time (since the form is modal). Therefore, the form will be reinstantiated each time you click the button.

  3. #3
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Question on creating new forms

    There are probably better ways to code the form instead of putting it in a module, just a matter of figuring out what exactly you are doing. You can try this three part article on working with multiple forms : http://www.devcity.net/Articles/94/1/multipleforms.aspx

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