Results 1 to 3 of 3

Thread: The working way of stopping errors when saving things?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2006
    Posts
    221

    The working way of stopping errors when saving things?

    Well i'm trying to save a file and i put in "on error goto _____" and then it went there all the time, even if there wasn't an error (aka pushing the cancel button).

    Is there not something else i can do to show what should happen when people press the cancel button when using the save/open command dialog boxes?

    If not, maybe i'm not placing my error thing in the right place. Could someone tell me where to put it in accordance to where it loads the save/load screen and in accordance to where it reads the file.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: The working way of stopping errors when saving things?

    VB Code:
    1. Private Sub Command1_Click()
    2. On Error GoTo Err1
    3. CommonDialog1.CancelError = True
    4. CommonDialog1.ShowOpen
    5. Exit Sub
    6. Err1:
    7.     'If cancel button is clicked
    8.     If Err.Number = cdlCancel Then
    9.     Exit Sub
    10.     End If
    11. End Sub

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: The working way of stopping errors when saving things?

    Does this help?
    VB Code:
    1. Private Sub Command1_Click()
    2. On Error GoTo blah
    3.     CommonDialog1.CancelError = False
    4.     CommonDialog1.ShowSave
    5.         'so something here...
    6.         Exit Sub
    7. blah:
    8.     MsgBox "Error #" & Err.Number & " - " & Err.Description, vbExclamation, "Error"
    9. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width