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
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.
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