 |
 |

04-22-2004, 06:05 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: Arkansas
Posts: 118
|
|
Cancel Unload
|
How would you go about canceling a form unload? i have this msgbox appear asking if a user wants to save a file that has Yes No Cancel on it. When the user clicks cancel i dont want the form to unload. How do i go about doing that? thanks.
cooldude4u2no
|
|

04-22-2004, 06:10 PM
|
 |
Hydrogen Powered
Administrator * Expert *
|
|
Join Date: Jul 2003
Location: Sacramento, CA
Posts: 6,090
|
|
__________________
"With the appearance of the AddressOf operator, an entire industry has developed among authors illustrating how to do previously impossible tasks using Visual Basic. Another industry is rapidly developing among consultants helping users who have gotten into trouble attempting these tasks." -Dan Appleman
|

04-22-2004, 06:20 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
|
To actually answer your question, the QueryUnload and Unload events both have a Cancel parameter. Set this to none zero to cancel the unload.
Do pay attention to webbone's link though. The distinction between the two events is important (although more so in MDI apps than SDI).
|
__________________
A wise one man once said "what you talking about dog breath"
|

04-22-2004, 06:25 PM
|
 |
Hydrogen Powered
Administrator * Expert *
|
|
Join Date: Jul 2003
Location: Sacramento, CA
Posts: 6,090
|
|
|
*L* I learn something new everyday! I've always used QueryUnload and never even noticed that Unload has a cancel as well.
|
__________________
"With the appearance of the AddressOf operator, an entire industry has developed among authors illustrating how to do previously impossible tasks using Visual Basic. Another industry is rapidly developing among consultants helping users who have gotten into trouble attempting these tasks." -Dan Appleman
|

04-22-2004, 06:30 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: Arkansas
Posts: 118
|
|
Quote:
|
Originally Posted by webbone
|
Thanks! It worked... One step closer to completing my personal project...woohoo! Thanks again!
|
|

04-22-2004, 06:33 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: Arkansas
Posts: 118
|
|
|
Ok another Question... How can i cancel the form from unloading when you press the cancel button on commondialog?
|
|

04-22-2004, 06:35 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
|
Set the CancelError property to true and wrap the call in an error handler.
|
__________________
A wise one man once said "what you talking about dog breath"
|

04-22-2004, 06:42 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: Arkansas
Posts: 118
|
|
|
Could you give me an example on how? Im clueless...
|
|

04-22-2004, 06:44 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
Code:
cdlg.CancelError = True
On Error Resume Next
cdlg.ShowOpen
If err.Number = 0 Then
' Do Stuff with cdlg.filename
Else
Cancel = True
End If
On Error Goto 0
|
__________________
A wise one man once said "what you talking about dog breath"
|

04-22-2004, 06:46 PM
|
 |
Hell's Angel
Retired Moderator * Guru *
|
|
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
|
|
Or alternatively:
Code:
cdlg.CancelError = True
On Error Goto CancelPressed
cdlg.ShowOpen
On Error Goto 0
' Do Stuff with cdlg.filename
Exit Sub
CancelPressed:
Cancel = True
End Sub
|
__________________
A wise one man once said "what you talking about dog breath"
|

04-22-2004, 08:31 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: Arkansas
Posts: 118
|
|
Quote:
|
Originally Posted by Banjo
Or alternatively:
Code:
cdlg.CancelError = True
On Error Goto CancelPressed
cdlg.ShowOpen
On Error Goto 0
' Do Stuff with cdlg.filename
Exit Sub
CancelPressed:
Cancel = True
End Sub
|
Thanks man! That answered all of my questions...now it should all be smooth sailing...i hope  lol...Thanks a ton.
Cooldude4u2no
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|