Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a program down completely. 2

Status
Not open for further replies.

PrograMan

Programmer
Jul 21, 2001
59
0
0
US
I've been trying to make it so that when the user clicks on the "X" on the upper right hand corner of the frame the program closes completely (as in, during development when the program running for testing it automatically goes back to the design window, like clicking on a "Close" button or something). I'm working with multiple forms here and just want to close it down correctly. I've tried Form2_Terminate, Form1.exitCmd_Click (exitCmd does exist). Or is it supposed to just be in limbo somewhere and I have to click on the "stop" button in the compiler environment to end the program entirely?
 
you can use End to completly close your program. But make sure you have done all necessary clean up before because end does not trigger the unload event.

Private Sub Form_Unload(Cancel As Integer)
'Any clean up code you have goes here
End
End Sub
 
Excellent. That's extremely helpful. But cleanup code... I've never done that for Vis BASIC. What kind of cleanup code are we talking about? You mean unload all forms and then end, or do I have to unload everything involved in the program?
 
I tried

Private Sub Form2_Unload(Cancel as Integer)

Unload Me
End

End Sub

Is that all the unloading needed? That's just the trick that ended the program like you said. But is that all?
 
The 'X' fires the Query unload event. In that event you can loop through all the forms closing each in turn. You should also take that opportunity to do your 'tidy-up'. This includes closing all external references to other apps, closing all database connections and setting objects to Nothing.

When all forms are unloaded the application ends. No need for End statement at all, as it's only a hangover from earlier versions of Basic.

I gave an example of closing all forms in thread222-736948 .

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
There is no external program sharing or database or anything. At the end of program design, all there should be is a single executable that will work on probably all Windows platforms. Therefore, no dlls or ocx or anything like that. This program only utilizes textboxes, scrollbars, menus, buttons, and labels. The list for all the unloading should be simple, right?
 
Yep, should just be the forms collection then

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top