ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Unload Event Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example demonstrates a simple procedure to close a form while querying
' the user with various message boxes. In an actual application, you could
' add calls to general-purpose SUB procedures that emulate the processing of
' the Exit, Save, and Save As menu items on Visual Basic's File menu.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Choose New Form from the File menu to create a form
' 3. Press Alt+F4 to return to the programming environment
' 4. Copy the code example below to the form module
' 5. Press F5 to run the example
 
 SUB Form_Unload (Cancel AS INTEGER)
     Msg$ = "Save Data before closing?"
     Response% = MSGBOX(Msg$, 3 + 32, "Save Dialog")
     SELECT CASE Response%
          CASE 2
               ' Do not allow close.
               Cancel = -1
               Msg$ = "Command has been canceled."
          CASE 6
               ' Enter code to save data here.
               Msg$ = "Data saved."
          CASE 7
               Msg$ = "Data not saved."
     END SELECT
     MSGBOX Msg$, 0, "Confirm"
 END SUB