Jomar Jomar - 2 months ago 13
Vb.net Question

Reset windows form without exiting the program

hello all? is there any way to completely reset a form on close or dispose?

I mean when you exit entire program everything will reset right.? so I want that without closing first form but closing only second one should do..!! Thanks

Answer

Oh, I misunderstood your question. In that case, you can use ShowDialog in Form1 like so:

Dim Cancel As Boolean = False 'you can set this true using whatever event suits your needs

While Not Cancel
    Using newform2 As New Form2
        newform2.ShowDialog()
    End Using
Loop

If I'm understanding what you need right, the code above will just keep opening new instances of that form until you tell it to stop. Honestly though, I really think you should consider having the form reset itself instead of closing and reopening it. If the form is coded in a modular way and most (or all) variables are of limited scope, then doing so should not require much code. Hope that helps though

Comments