• Log in or sign up for an account here: https://www.sythe.org/login

[SOURCE] Promot Exit [/SOURCE]

Darthatron

Massive Troll

Retired Sectional Moderator
Visual Basic Programmers
Joined
May 22, 2006
Sythe Gold
0
Messages
1,612
Age
35
Location
The internet.
seems easy enough but for all the new guys... well basically it seems like something you might want to know.

Firstly put this is General Declarations...
Code:
Dim Response As Integer

Next we will go to "Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)", you could also use "Private Sub Form_Unload(Cancel As Integer\)" but I have been informed that the first way is cleaner...

So put this in "Form_QueryUnload"...
Code:
    Response = MsgBox("Are you sure you want to exit?", vbYesNo, "Exit?")
    If Response = vbYes Then
        Cancel = 0
    Else
        Cancel = 1
    End If

Now when you go to exit the program you will be promoted and when you click yes it will close and when no is clicked nothing will happen!

-Darthatron
 
Already know how to do that, but i guess its good for the people new to vb and lechers.
 
Well yes, most people do know how to do it and it is really just for the Leechers... but thanks for the comment!
 
Member of the Month Winner
Sythe's 10th Anniversary
Props for trying to help, but any person with a half decent knowledge of BASIC can do this, let alone microsoft's rip of the language >_> lol.

Ah well, As I always say, should help at least SOMEONE :)
 
END sometimes doesn't work.

This is probably the best way.
Code:
Dim frm As Form

  ' Loop through all open forms and close them
  For Each frm In Forms
              Unload frm
  Next frm
 
END sometimes doesn't work.

This is probably the best way.
Code:
Dim frm As Form

  ' Loop through all open forms and close them
  For Each frm In Forms
              Unload frm
  Next frm

You'll need to change that ^^ to this:
Code:
Dim frm As Form

  ' Loop through all open forms and close them
  For Each frm In Forms
        if not frm.name = me.name then
              Unload frm
        end if
  Next frm
  unload me
 
Runescape Gamblingrunescape gambling
Back
Top