Unload for my Form1 ?

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
 
D

Doug Glancy

Joe,

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

hth,

Doug
 
J

Joe

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"

:(
 
R

RobinS

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

Joe

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
 
A

Armin Zingler

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
 
J

Joe

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

lord.zoltar

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?
 
J

Joe

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!
 
A

Armin Zingler

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
 
C

Cor Ligthert [MVP]

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
 
R

RobinS

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top