|
-
Jun 10th, 2003, 12:18 PM
#1
Thread Starter
Lively Member
Error Handling
Hi All;
I put the On Error Statment and write the error handling but the error still apeare when I click the cancel button in the common dialouge box. This is my code for this.
Private Sub Command1_Click()
On Error GoTo ErrorHandler
CommonDialouge1.CancelError = True
CommonDialouge1.DialogTitle = "Save Playlist File"
CommonDialouge1.Filter = "All Files (*.*)|*.*|Text (*.txt)|*.txt"
CommonDialouge1.FilterIndex = 2
CommonDialouge1.flags = cdlOFNExplorer Or cdlOFNLongNames Or cdlOFNPathMustExist Or cdlOFNHideReadOnly
CommonDialouge1.FileName = ""
CommonDialouge1.ShowSave
If Trim(CommonDialouge1.FileName) = "" Then
Exit Sub
End If
ErrorHandler:
Select Case Err.Number
Case cdlCancel
CommonDialouge1.FileName=""
Resume Next
End Select
End Sub
-
Jun 10th, 2003, 12:20 PM
#2
Addicted Member
the only think i can see is your missing the : after this On Error GoTo ErrorHandler
you have:
VB Code:
On Error GoTo ErrorHandler
should be:
VB Code:
On Error GoTo ErrorHandler:
and you need to have an exit sub in there that is used everytime not jst when CommonDialouge1.FileName = "".
Do you get the same error as you did before you put in the error handler. or do you get a different one
hope that helps
Last edited by big_k105; Jun 10th, 2003 at 01:08 PM.
-
Jun 10th, 2003, 12:44 PM
#3
PowerPoster
Re: Error Handling
Originally posted by Bobbo70
Hi All;
I put the On Error Statment and write the error handling but the error still apeare when I click the cancel button in the common dialouge box.
no entiendo ..
it should raise an error if you click cancel. looking at your code it seems that you realize this tho. please help me understand by rephrasing your question.
-
Jun 10th, 2003, 01:39 PM
#4
You need an exit sub before the error handler. Without explicitly telling the sub to exit, execution will proceed right on into the error handler whether you have an error or not.
I guess I'm unclear on whether that will solve your particular problem, but if that's not the problem, and you don't make this change, you will have further problems with that code.
Last edited by Shaggy Hiker; Jun 10th, 2003 at 01:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|