Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Exit Button Coding

How do i add some coding on the Exit (X) on the top left corner?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Remove Exit Button But Leave Minimize Button
How can I remove the exit button on the top right corner of a form, while leaving the minimize button?

Blocking The 'X' Button (exit Button)
I have one main question right now. I have a program that is a just a test of my programming skills as I am currently learning Viual Basic 6.0. It is a joke program where one command button will exit the program if pressed twice and the other will move out of the way to a random place on the form when you move the cursor over it. The joke is that it says "BYU RULES!" and asks "do you agree?" The YES! button is the button that will exit the program if you click it twice. The "no, not really" is the one that moves. I give the program to U of U fans who of course will try for the "no, not really" button and it will move. So they try to outsmart me and use the keyboard. I put a message box with the title "you're feeling pretty clever, right?" and the text "Congratulations! You pushed the Evil Button of Doom!" and just has an OK button. I've also blocked them from resizing it and moving it around the screen. The thing is, I want them to have to push the "no, not really" button. I don't wnat them to do what they usually do when they see that all else fails which is click the 'X' button to exit the program in the top right corner of the screen. I've taken off the Minimize and Maximize buttons, but I want to also block the 'X' button. Is there a way to make it System Modal so they can't exit without the built in way? Please get back to me as soon as you can.

Exit Button
Hello, all,

I created a command button "Exit", which meant to exit and close current running programme, what command should I use to ensure all the memory also has been released? Thanks a million!

Exit Button
I have VB 6.0 and I was wonder where I would type it in at and what I would type to remove the exit button thats at the top of every form?? And possibly the other commands on that bar...

EXIT Button
Hi guys. Can you remind me how to make a button that closes the program? I just have a simple 1 window thing, and want to disable the X in the top right corner, so that they need to go through all the prompts before an exit button appears.

Thanks.... Sorry I am asking newbie questions


Exit Button
I see that the form properties has a setting to allow you to turn off the maximize and minimize buttons. Is there a way to turn off the exit button as well?

Exit Button
I'm new with VB and i was wondering how to make an exit button. I could buy a book about it, but this is alot cheaper. So if anybody knows, i'd be glad to hear it from you!


An Exit Button
hello everyone, i have this project, and i want to have an exit button which will display a message yes/no box, only problem is i cant get it to actually do anything depending on what button i press
 here is the code i have but i dont think its right cauyse it dosent work

Private Sub cmdEnd_Click()

cmdEnd = MsgBox("Are you sure you want to exit?", vbYesNo, "Exit")
If vbYes Then
End If

End Sub

Title Bar Exit Button
is there a way to disable the exit button in the title bar (beside minimize and maximize) ?

Disable Exit Button???
can someone post a sample code on how to disable the EXIT button @ the upper right corner of the form, i know that by using API, the EXIT button will disable, but i dont know how coz im a newbie in vb6.thanks in advance
the minimize and maximize button is enable, only the EXIT button is the one i want to disable.

Disable Exit Button
Hi Everyone,

Is there a quick way to either disable the Exit 'X' in the top right corner?

I have searched this site and tried some of the suggestions for this, but they have no effect on my forms (is this because I am using VBA rather than VB6?).
Basically some fields on my main form open up a new smaller form where the user can either enter values, or exit without saving. The smaller form has 2 buttons, one to quit wihout saving, the other to save and close (both returning to my main form). I have just realised that the user can close the form with the exit button which makes my buttons pretty pointless - i.e. they can enter values - then quit the form using 'X' and no values are kept. Can I either disable the X or at least make it invisible, or add some additional code to it that forces the user to chose one of my buttons? One piece of code I have tried from the site is as follows:

[vb Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
Cancel = 1
End If
End Sub /vb]

Exit Command Button How To?
Hi guys I just finsihed one form and I want to add a exit command button so everytime when I press the button the program will exit by itself. Does anyone know what kind of codes do I need to create this exit button?

any info would be greatly appreciated!


Exiting Using An Exit Button
I have an exit button on a form and I want to exit that form and go to the previous form I was on. Could some one please help me out with this. I know that it's simple, but I am a total beginner at this. Thanks

Exit Button...what A Hassle!
Could sombody provide the code to disable the "X" in the top right corner of a form.

Any help would be appreciated.


"I dont know, ask the other guy."

WebBrowser And Exit Button
Two questions here
First of all this is an easy question, kinda embaressed here, just isnt working out. I'm trying to get it so on command1_click wb navigates to a, then once the page is fully loaded it inserts some data and thats it. i tried coding it

VB Code:
Private Sub command1_click()wb.Navigate ""Do While wb.Busy = FalseSet blah = wb.Document.getelementsbyname("one").Item(0)Set blah2 = wb.Document.getelementsbyname("two").Item(0)blah.value = "one"blah2.value = "twoLoopEnd Sub

but it endlessly looped and froze up.

another question is how to monitor when the "X" button is clicked on my form. i've seen it done a lot i just dont know how. so when it is clicked i can call my own code, the reason being is that sometimes my programs wont completely close when i hit "X" so i want to make it end, and also i would like to be able to minimize the form when the x button is clicked

thanks for all the help

Programing The X (exit) Button

In the Right hand top corner of every page is a X (Exit) button.

Is there anyway to program the code for this?

The reason I ask is because when I click it (On my program's window) It closes the app BUT does not close it in the Taskmanager window.

Thank you for any help you may have!


Create An Exit Button
Wot code do u write 2 exit a program correctly??

Using VB version 6

Form Exit Button
For each form there are 3 menu buttons: min,max and exit.
How can I set the buttons that the min and max should be
enabled = true and the exit button should be enabled = false?
(API function?)
Thank you

Form With No Max, Min, And Exit Button.
How do I make is so there will be no buttons on the title bar? That means no Max, Min, or Exit buttons. If you know how, please tell me. Thx in advance.

How To Remove The Exit-button?
Hello there!

-I want to remove the whole "upper-bar"( where the minimize-, maximize- and exit-buttons are ) in my program.

-I`ve removed the maximize and minimize buttons, by setting their property to false in the form, but how do I do this with the last one?

Exit Button Invisible?
Is there a way to make the exit button on the top right corner invisible, not just disabled, without setting the controlbox to false. Thanks.

Code On An Exit Button......
I am trying to find out the code that i am supposed to enter into the exit command. (the way that people click file then exit).

I basically want this to terminate the program.

Can anyone tell me what to type?

Thanks in advance.

Txt_LostFocus And Exit Button
Hi All

I put a condition in text_lostfocus event to check the whether it is empy
and display msgbox. But if some one directly press the Exit button on the
form, then also before exiting the same msgbox appears and focus is set n
Exit button and hence user has to press the Exit button once again in orer
to exit the form.

I wish that the msgbox is not being displayed if the Exit button is press
irrespective of value of Text Box. How can I achieve this. Any help willbe
awarded a big THANKS.


Rajiv Kumar


Dynamic Exit Button
How can I generate an exit button that remembers where I load the form from and upon exit, I reload the current form I had load the form from. Like if I am in form 1, I load form 2 on exit form 2 I get back to form 1. If I am in form 3, I load form 2 and exit I get back to form 3.

Disable The Exit Button
Is there a way to disable the exit button in a window but keep the minimize one on? Thanks

How Can I Set MDIChild Form Without Exit Button?

I tried to set a MDI child form without the exit button on the upper right hand corner but want to keep the maximized and minimized buttons. But if I set the ControlBox value to False, all buttons are gone.

Any idea?



MDIForm Exit Button Disable

I currently have a mdiform with some childform
When the user presses on the x-button (top-right button) of the mdiForm, the application closes.
I can stop this from happening by editing the MDIForm_Unload event, but my loaded childforms get unloaded whatever I do.
My question: how do I stop the application from exiting when a user presses the x-button without unloading my mdichilds.

I have something in mind like: Do you really want to exit? Yes-No
but ofcourse when the user presses No, the child forms who were already loaded should still be there.

Thanks in advance!


Question About The Text Box And Exit Button?
hi I'm just wondering is there anyway to force a textbox to only allow the character inputs and no more than 25 characters in a box? do I need to dim is as string?

Another question is that how do I make a exit button that will pop up a box that asking user if he really wants to terminate the program? I know the code for exit is unload me.

any info would be greatly appreciated

thx a lot!

Exit (x) Button And Font Color
Ok n00b here again....

Can't figure out how to remove the "x" button from the top right of the form

How does one set the font color on a Command Button?

Exit Loop Using Command Button
I am writing a program which has a loop which updates the value of a text box based on information its receiving from the serial port. Is it possible to jump out of this do loop using a command button click. It doesn't seem to register that I've clicked the exit command button until the loop has ended.

Exit Button And How To Save A List
Hi guys i am working on a program for school and i would like to have an exit button (command) no idea for the codes and the others things is for how can i save what i have in a textbox. what i mean is this i have a list with 2 name inside, example dean and dean1 if i click on dean1 a form open with an textbox having all the information regardding this name. if i click on dean same thing hapen. What i would like to do is probably hard. I would like to be able to save all my textbox into a file on drive C: and also i need to have a button to add more people into my list ...

anybody can help please i just dončt know what to do... i am lost thanx guys !!!

Can You Close This Program Without Using The Exit Button??!
Hi! I've rewritten a portion of code of an old security program of mine. You are welcome to download it and use it if you want.

Can you close the program (in High Security mode) without using the Exit button?

Please download it and try it, If you can't close it without the Exit button, then post a message saying so.

This is SERIOUS work!


- List all windows/handles in the system.
- Show/Hide/Terminate any process.
- Auto-Hide List will automatically hide all windows matching any criteria in the AH-list.
- Password protected (And encrypted)
- HotKey Enabled (To show/hide the program)
- Advanced Modes (Lists also hWnd number)
- Log files
- High Security (UNTERMINABLE)

When the program starts, "nothing" will happen until you press the default hotkey Ctrl+Alt+A. The program wont ask for a password if the password is "" (which it is by default).

Practically, what I want you to do is go to Advanced Mode by clicking the Arrows, then checking the "High Security" checkbox. Then hide the program again (using the hotkey), and do what ever you can to shut the program down or terminate it.

If you can succeed in terminating the program (when it is hidden and in High Security mode) please tell me how you did. I myself have tried everything, and I just couldn't terminate it So I'm asking you to help me find a vulnerability...

That is, of course, if you even find the program in your task list.

Also tell me of any errors you encounter and how to reproduce them.

Note: Source is not attached because it contains code from a commercial project.

So... Can YOU terminate Api Manager?

Exit Command Instead Of Stop Button
what is the code for if you had an exit command, which would stop the program. You would do this instead of clicking the stop icon at the top of the screen

Canceling An Exit When The X Button Is Click.
In the docs it says that the unload event is always run before the terminates.

However in my program I have a message box popup asking if the user wishes to save before exiting with a vbYesNoCanel and if the user hits cancel I have:

if query=vbcanel then Cancel = -1

In the docs it says making Cancel anything other than 0 will halt unload (and in theory terminate) this code only works when I hit the exit in my File menu.

So... that brings me back to the topic, how to I hate a close when the X button is pressed.

When A User Hits The Exit Button
Hi, How can I get my program to carry out an instruction before the user hits the X button to close the form?

Exit Button On Right Hand Corner
Is there a way to disable the exit button in a vb form like the way with the min and max button, and if not, is there a way to put some kind of event with it? Thank you

STOP Button To Exit Procedure, HELP HELP!!!!!!!!

I really hope some genius of you vb gurus can help me out here. I'm sure the solution must be simple, but *damn* I've been trying and I can't get out of it.

Let's say I've got a control1 on form1. In the Control1_Click Sub, I just have a counter, that works like this:

Private Sub Control1_Click
Dim a as Long
For a = 1 to 100000000
'What here??????
next a
End Sub

What I need is to be able to STOP this counter from going on when the ESCAPE key is pressed on the keyboard, AT ANY MOMENT.

I want just a stupid trigger that allows me to exit the Sub!

Right now, the counter simply has to finish before I can actually access to any other part of the program.

Please help me out!!

Thank you very very much in advance,


Exit A Subrouting When Clicking A Button?
I have a subroutine which does things in a while loop after I've clicked a button:

Private Sub scan_Click()
mmFind (sFile)
End sub

Private Sub mmFind(ism)
End sub

When I click a stop button (in a stop_Click() subroutine), I want to exit the subroutine (ie the while loop) and stop the program. I've heard of DoEvents but can't find any simple example anywhere. Are DoEvents what I need and if so can somebody help me out?

How Can I Make This Exit Button Work? ...

I have an `Exit` button on my game which is in the `File` Menu. I want it to display this message box "Do you really want to quit?", then have the option to select Yes or No (vbYesNo). How can I then attach to the `Yes` button to unload the form and the `No` button to return to the game?

Any Info would be appreciated



Exiting Application With Exit Button
Maybe this is very simple but.

How can I make an exit button to exit my application??

Gr Johan

Disable Exit Button On A Form
a qucik simple one,

how do you disable the close button on a form?


Exit-Button In A Data Report
Hello !

When I create a data report there are only the "print" and the "export" buttons available. Is there
a way to insert a "Exit"-Button at runtime also ?

Thanks in advance ...

Kind regards,


Enabling Form At After Clicking Exit Button
Theres probably a simple answer to this.
I wan to enabled a form when I exit another form via the exit button in the corner.


Thanks in advance

How To Encorporate An Exit Command, Instead Of Stop Button
I was wondering, what the code would be, so that you could just hit an exit command, and it would stop the program instead of going to the top and hitting the stop button.

Removing The Exit Button [X] From An MDIChild Form
I am having trouble removing the Exit button [X] from an MDIChild form. This is probably a simple thing to do but I can't for the life of me figure out how. If you could help that would be great.

Problem With EXIT-button On A MS Access Form

I have this strange problem with a form in an Access application. The form is quit simple with some labels, textboxes and one combo box on it. There is also a command button to close the form. The code behind this button is is also quit simple:
Code:DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name

If I open this form and close it immediately I have to click twice on the command button. If I change some text in one of the textboxes or change the value of the combo box, I only have to click once as it should be.

Any ideas what maybe the cause of this strange behaviour?

Edited by - ELOOP on 11/13/2007 4:24:05 AM

Help With Button Coding

I'm creating a simple program where the applicants add in their information and I want that information sent to me through e-mail by clicking a button. How may I do this? Whats the code?


Overriding Text _validate Event For Exit Button
I had a coupla questions regarding textbox events
1) I have an exit button on my screen which needs to be active, i.e the users can exit the form..but i am doing some text validation(checking for null) in the Textboxes on that form using the text validate event so now it basically forces the user to enter values before they can click exit..(keeps popping error messages until they do so) . any way out???

2) I also need to right justify the numbers that they enter in the textboxes. i.e . the numbers have to start from right to left once the textbox loses focus...

can smbdy help me????

thnx in advance!

Problem With The Exit Button In Combination With Txt_lostfocus Event.
On a form i have a button to exit the form.
I have also several text controls on the form.
I have embeded validation code for the lostfocus event of the text controls.

My question is Is How can i bypass the evaluation of the code written within the text_lostfocus sub procedure when I click on the exit button.

Kindly indicate a suitable alternate method if the present approach is not feasible.

Copyright © 2005-08, All rights reserved