473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Handling The Close [x] Button Of A Form

Kabyr
29 New Member
Hi everyone,
Can someone help me with a procedure to handle the clicked event of the Close button (The [X] button on the top right coner of a VB form. I want to be able to query the users intention for clicking, like: Does he want to save before closing ... instead of just closing the window.

I used a command button to achieve this but I also want to do same for the Close button.
Nov 29 '07 #1

✓ answered by Killer42

The details will depend on what version of VB you're using.

In VB6 you would use the form's QueryUnload and/or Unload events.

13 11260
numberwhun
3,509 Recognized Expert Moderator Specialist
Hi everyone,
Can someone help me with a procedure to handle the clicked event of the Close button (The [X] button on the top right coner of a VB form. I want to be able to query the users intention for clicking, like: Does he want to save before closing ... instead of just closing the window.

I used a command button to achieve this but I also want to do same for the Close button.
Please, DO NOT post questions in the Member Introductions Forum. Heck, there is even a thread with a title asking you not to.

I am moving this question to the VB forum.

Regards,

Jeff
Nov 29 '07 #2
Mohan Krishna
115 New Member
Hi everyone,
Can someone help me with a procedure to handle the clicked event of the Close button (The [X] button on the top right coner of a VB form. I want to be able to query the users intention for clicking, like: Does he want to save before closing ... instead of just closing the window.

I used a command button to achieve this but I also want to do same for the Close button.
Hi
Try...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Terminate()
  2.     MsgBox "Hai"
  3. End Sub
  4.  
ALL THE BEST!
respond is it helpful...
Nov 29 '07 #3
Killer42
8,435 Recognized Expert Expert
The details will depend on what version of VB you're using.

In VB6 you would use the form's QueryUnload and/or Unload events.
Nov 29 '07 #4
lotus18
866 Contributor
The details will depend on what version of VB you're using.

In VB6 you would use the form's QueryUnload and/or Unload events.
But it depends on the form and/or type of application. Let us say for an instance we have 1 form and containing all the list of any record, then when adding/modifying a particular record we're using another form and it is shown as vbmodal. What if the user add new record, how can you unload that form without prompting a message box? : )

Rey Sean
Nov 30 '07 #5
Killer42
8,435 Recognized Expert Expert
But it depends on the form and type of application. Let us say for an instance we have 1 form and containing all the list of any record, then when adding/modifying a particular record we're using another form and it is shown as vbmodal. What if the user add new record, how can you unload that form without prompting a message box? : )
Seems to me, that's way off-topic for this thread. We're dealing with kind of the oposite - what to do when the user clicks Close.

You probably should start a new discussion for your question, including as much detail as possible about the situation.
Nov 30 '07 #6
lotus18
866 Contributor
Hi Killer42

I was only just gave my opinion and it was relevant to the topic. I'll post that question soon : )

Rey Sean
Nov 30 '07 #7
Mohan Krishna
115 New Member
Hi Killer and Lotus,

Very good discussion!
Here we can use any of the above Form Events.
But as Lotus raised a question, it makes some problem when another form is shown MODAL. Please Lotus post a new thread and we try to get a solution.

But where is Kabyr whether he got the solution from this good discussion.
Thank you both of you!

This is my 100th post.

Thank You ALL!
Nov 30 '07 #8
lotus18
866 Contributor
Hi Killer and Lotus,

Very good discussion!
Here we can use any of the above Form Events.
But as Lotus raised a question, it makes some problem when another form is shown MODAL. Please Lotus post a new thread and we try to get a solution.

But where is Kabyr whether he got the solution from this good discussion.
Thank you both of you!

This is my 100th post.

Thank You ALL!
Hi Mohan

Congrats for your 100th post. haha...

I think Kabyr got the solution from this forum. OK, I'll post the question later, I have some work out here. lol : )

Rey Sean
Nov 30 '07 #9
9815402440
180 New Member
hi

use following code

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("do you want to close this form", vbYesNo) = vbNo Then
Cancel = 1
End If
End Sub

regards
manpreet singh dhillon hoshiarpur
Nov 30 '07 #10
Mohan Krishna
115 New Member
Hi Mohan

Congrats for your 100th post. haha...

...lol : )

Rey Sean
Thank You Lotus!
This is a very good and quick responsive forum!
Nov 30 '07 #11
lotus18
866 Contributor
Thank You Lotus!
This is a very good and quick responsive forum!
Hello Mohan

I've just posted the question as you requested : )
As you've said, this will gonna be interesting lol (haha)

Rey Sean
Nov 30 '07 #12
Kabyr
29 New Member
Thanks everyone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Form_Unload did the job.

You made my day.
Dec 1 '07 #13
Killer42
8,435 Recognized Expert Expert
Glad we could help. :)
Dec 13 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Andy Kowaluk | last post by:
I have an intranet site that connects to an access database using ASP (Javascript). > Currently, when an user attempts to enter a duplicate value into the > database it is rejected and the user is...
4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
4
by: ronenk | last post by:
I have this code to load an authentication form once my app is loaded. I want the authentication form to be closed if a user is authenticated successfully and to give the option to close app on his...
2
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how...
2
by: Rob Richardson | last post by:
Greetings! I am struggling to understand data binding in VB.Net, and it's slow going. I have a list box bound to a dataset that is filled from a SQL Server table. In addition to the list...
4
by: Tad Marshall | last post by:
Hi, I'm having limited luck getting an ApplicationException to work right in my code. This is VB.NET, VS 2003, Windows XP SP2, .NET Framework 1.1. I thought it would be convenient to take...
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.