Closing forms

Nicko101

Member
Joined
Aug 31, 2004
Messages
10
Programming Experience
Beginner
How do i close a form so that it cannot be seen or used, all textboxes etc. are returned to their default values and it can be opened with Dim ... As New declaration. I tried this code:

VB.NET:
 Dim form1 As New Form1() 

form1.Show()

Me.Close()

but this only brought up the second form without closing the first. Help please anyone.

Nicko101
 
in a module, Public myform1 as form1

first form:

myform1 = new form1

me.close

that should open a new form and close the currently opened one
 
Or you could use the following code which is similar to what you had:

VB.NET:
 'Specify that form1 is the form to create. 
Dim frm as new form1
'Show the form
frm.show
'Hide the form that launched it
me.visible
Note: this does not acutally close the form but instead it will hide it. The user will not know the difference, but when you close the program it will not longer be there, and to get it back you simply have to change the me.visible parameter to true.
 
That might work, but i think i have solved the problem. If i make the second form a dialog box of the first, and set the dialogresult property of one of the buttons, that should work fine for what i need.
 
dispose first form...

create a code that will dispose the first form then create a new instance of the form.
 
code

If TRANSrem Is Nothing OrElse TRANSrem.IsDisposed Then TRANSrem = New frmTRANSrem

TRANSrem.MdiParent = Me

TRANSrem.Show()
 
Back
Top