Unload for my Form1 ?

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

why is that

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

works fine, but

Public Sub Form1_Unload(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

seems not to work at all ? what is a valid function name during
unloading (through clicking "X" in right corner of the Form1 window).
Note Form1 is my main window.


Thanks
 
Joe,

I believe the 2nd one needs to say "Handles MyBase.Unload", in any case not
"MyBase.Load".

hth,

Doug
 
Joe,

I believe the 2nd one needs to say "Handles MyBase.Unload", in any case not
"MyBase.Load".

unfortunately, MyBase.Unload does not exist, neither "Close", "Exit",
"Quit" or "CloseThreat"

:(
 
The second one assigned the load event to the unload routine.

If you are trying to capture the unload event, look at Form_Closing, not
Form_Unload.

Robin S.
 
Public Sub Form1_Closing(ByVal sender As System.Object, ByVal e As
System.EventArgs)

MsgBox("g-bye!")

End Sub


does not show this message.

note that my main form is "Form1"


Form1_Load works however
 
Joe said:
Public Sub Form1_Closing(ByVal sender As System.Object, ByVal e As
System.EventArgs)

MsgBox("g-bye!")

End Sub


does not show this message.

note that my main form is "Form1"


Form1_Load works however


"Handles" is missing.


Armin
 
wel.. handles what? MyBase.Unload? not exist...MyBase.Closing? not
exist... MyBase.Quit? not exist...
MyBase.Load will work just on loading form not on unloading...
 
wel.. handles what? MyBase.Unload? not exist...MyBase.Closing? not
exist... MyBase.Quit? not exist...
MyBase.Load will work just on loading form not on unloading...

Maybe the events you are looking for are FormClosing or FormClosed?
 
ok, finally the answer is:

Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal
e As System.Windows.Forms.FormClosedEventArgs) Handles
MyBase.FormClosed


thanks anyone!
 
Joe said:
wel.. handles what? MyBase.Unload? not exist...MyBase.Closing? not
exist... MyBase.Quit? not exist...
MyBase.Load will work just on loading form not on unloading...

...Handles mybase.formclosing


Armin
 
Joe,

As was told to you already by Armin Zingler some rows before, where you gave
the nice answer.

"wel.. handles what?"

It is strange that Armin and Lord Zoltar were going on helping you.

You are completely helped to come to your answer and did not even thank

Cor
 
Just FYI, there are two events -- Form_Closing and Form_Closed.
Form_Closing fires before you close the form, and can be cancelled.
Form_Closed fires *after* the form hasclosed.

Robin S.
-----------------------------------
 
Back
Top