how to close all forms open?


hello, im making an RPG and i have a pause menu setup to where it shows over the game screen. i have a quit button, and i want to know the code that will make that quit button close all forms. any help will be much appreciated thanks.

Better way

Public Sub CloseAllForms()
Dim Frm As Form
Unloadfrms:
Frmlist = ""
For Each Frm In Forms
Frmlist = Frmlist & Frm.Name & vbCrLf
Unload Frm
Set Frm = Nothing
Next
' uncomment line below for debugging
'Msgbox Frmlist
If Frmlist <> "" Then
Goto Unloadfrms
End If
End Sub

Close All Forms

Well its easy enough to close all Forms your app is using with. Just add this Sub to a Module so it can be called from any Form.

Public Sub CloseAllForms()

Dim Frm As Form

For Each Frm In Forms
Unload Frm
Set Frm = Nothing
Next

End Sub

Keith
www.martin2k.co.uk/forums/

I've been programming with VB for 13 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options