Results 1 to 7 of 7

Thread: [RESOLVED] FileCopy

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] FileCopy

    Everything seems to be working but the highlighted part isnt. Please advise. Thanks in advance.
    VB Code:
    1. Private Sub cmdBackupRegistrationFile_Click()
    2. 10        On Error GoTo cmdBackupRegistrationFile
    3.           Dim intRet As Integer
    4.          
    5. 20        intRet = MsgBox("You are about to backup your registration file for" & vbNewLine & _
    6.                  "Braille Quick Reference Guide (Version: " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNewLine & _
    7.                  "Please click Yes to complete backup or click No to cancel the backup." & vbNewLine & vbNewLine & _
    8.                  "Make sure that you have a floppy disk in your floppy disk drive before you continue.", vbYesNo + vbQuestion, "Backup Registration Information?")
    9.                  
    10. 30        If intRet = vbYes Then
    11. 40            FileCopy (App.Path & "\licence.lic"), "A:\licence.lic"
    12. 50            MsgBox "File copied to your floppy disk successfully!", vbInformation, "File Copied Successfully!!"
    13. 60        Else
    14.               'do nothing
    15. 70        End If
    16.          
    17. 80        [hl]If Err.Number = 76 Then
    18. 90            MsgBox "You do not have a floppy disk in your" & vbNewLine & _
    19.                      "floppy disk drive!", vbExclamation, "Floppy disk not found."
    20. 100       End If[/hl]
    21.          
    22. 110       Exit Sub
    23. cmdBackupRegistrationFile:
    24. 120           WriteToErrorLog "BRG"
    25. End Sub

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: FileCopy

    On Error GoTo cmdBackupRegistrationFile

    This causes it to skip everything and go straight to the error trap. Therefore your code will never run if there is an error.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: FileCopy

    Quote Originally Posted by Andrew G
    On Error GoTo cmdBackupRegistrationFile

    This causes it to skip everything and go straight to the error trap. Therefore your code will never run if there is an error.
    ok thanks. didnt see it. the problem is now that i am not getting the message box and if the path is not found (error 76) then the app just closes. any suggestions?

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: FileCopy

    Leave the on error goto statement in, but move lines 80 to 100 to below the cmdBackupRegistrationFile label.
    Frans

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: FileCopy

    Is the error number 75 or 76 cause if the error number is wrong then the msgbox won't show.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: FileCopy

    Quote Originally Posted by Frans C
    Leave the on error goto statement in, but move lines 80 to 100 to below the cmdBackupRegistrationFile label.
    like this?:
    VB Code:
    1. Private Sub cmdBackupRegistrationFile_Click()
    2. 10        On Error GoTo cmdBackupRegistrationFile
    3.           Dim intRet As Integer
    4.          
    5. 20        intRet = MsgBox("You are about to backup your registration file for" & vbNewLine & _
    6.                  "Braille Quick Reference Guide (Version: " & App.Major & "." & App.Minor & "." & App.Revision & ")" & vbNewLine & _
    7.                  "Please click Yes to complete backup or click No to cancel the backup." & vbNewLine & vbNewLine & _
    8.                  "Make sure that you have a floppy disk in your floppy disk drive before you continue.", vbYesNo + vbQuestion, "Backup Registration Information?")
    9.                  
    10. 30        If intRet = vbYes Then
    11. 40            FileCopy (App.Path & "\licence.lic"), "A:\licence.lic"
    12. 50            MsgBox "File copied to your floppy disk successfully!", vbInformation, "File Copied Successfully!!"
    13. 60        Else
    14.               'do nothing
    15. 70        End If
    16.          
    17. 80        Exit Sub
    18. cmdBackupRegistrationFile:
    19. 90        If Err.Number = 76 Then
    20. 100           MsgBox "You do not have a floppy disk in your" & vbNewLine & _
    21.                      "floppy disk drive!", vbExclamation, "Floppy disk not found."
    22. 110       End If
    23. 120           WriteToErrorLog "BRG024"
    24. End Sub

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: FileCopy

    Quote Originally Posted by Andrew G
    Is the error number 75 or 76 cause if the error number is wrong then the msgbox won't show.
    76, was a typo in the post, updated it.

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