Link to home
Start Free TrialLog in
Avatar of Kael1
Kael1

asked on

How do I program the x button?

How do I program the x button in the top right to do whatever I want?
Avatar of JuanCarniglia
JuanCarniglia
Flag of Argentina image

You don't do that exactly, but you can do this.

Capture the Event (Unload) on that form, and choose to close it or not, or to do something else.
Try this:

------

Private Sub Form_Unload(Cancel As Integer)

    MsgBox ("This will appear when I click the x button !!! ")

    if (I_Want_To_Close_This_Window) Then
           
           'Close all files and handles

           Cancel = 0      'This means that this event will get passed on
    Else
           'Do something else

           Cancel = 1     'This means that this event will NOT get passed on
    End If

End Sub

-------

Greetings
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial