What's the equivalent of Unload form1 in VB.net

  • Thread starter Thread starter Sender
  • Start date Start date
S

Sender

In VB6.0 we use Unload Form1 to unload (close) form1 -
what shall we have to write to unload a form in VB.Net
 
Dim myForm as Form1 (assuming)

myForm.showdialog()
myForm = nothing

or you could call .Dispose() but garbage collection usually does that on
setting it to nothing.

-CJ
 
So its your application starting point. in which case, when you close the
form on its own, the entire application will exit. you don't have to do
anything because you are not creating the instance of the form.

-CJ
 
See... I don't want to close the form1 by clicking on the
CLOSE (x) button of the form. I want to create a button
CLOSE and wherein I want to write code to close the form
(entire application).
 
oh

me.close


Sender said:
See... I don't want to close the form1 by clicking on the
CLOSE (x) button of the form. I want to create a button
CLOSE and wherein I want to write code to close the form
(entire application).
 
Sender said:
I don't think the code you gave works. I am not creating a
form through code. The form1 is already there when I open
the blank solution (and VB project). Then I inserted just
one button titled 'CLOSE ME' where in I wrote the code you
have given. But it shows error.

Simply add the code below to the button's 'Click' event handler:

\\\
Me.Close()
///
 
Sender said:
See... I don't want to close the form1 by clicking on the
CLOSE (x) button of the form. I want to create a button
CLOSE and wherein I want to write code to close the form
(entire application).

You can use 'Application.Exit', but that's very "burtal". It's better
to unload all the forms by calling their close method. Do you have more
than one form? Where do they get instantiated?
 
Back
Top