Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Cannot Trap Runtime error 481 Invalid Picture ?????

Last post 23 Jan 2007, 3:31 PM by drfgb. 3 replies.
Sort Posts: Previous Next
  •  27 Feb 2004, 12:56 AM 4594

    Cannot Trap Runtime error 481 Invalid Picture ?????

    This is driving me crazy.

    I have a routine that loads a jpg picture into a picturebox.  Here is a code
    snipit:

     On Error GoTo ErrorThumb1
            Thumb(1).Picture = LoadPicture(Filename1)      'where Filename1 is a string variable that holds the complete file path and name
            Thumb(1).Visible = True                                 'Thumb(1) is the second Picture Box in a control array
                    Thumb(1).Refresh
                    lblID1.Visible = True
                    lblID1.Refresh

    At the end of the subroutine I have the error handlers as follows:

    ErrorThumb1:
    Load frmDialog                                      'This is a custom form I use to display Error information to the user
    frmDialog.txtMessage.Text = Str$(err.Number) & " Loading Thumbnail 1." &
    vbCrLf _
    & err.Description & vbCrLf & Filename1 & " is not able to open."

            Thumb(1).Picture = LoadPicture ' placeholder for Image not
    available.jpg
            Thumb(1).Visible = True
                    Thumb(1).Refresh
                    lblID1.Visible = True
                    lblID1.Refresh

    Resume Next

    Yet every time it tries to load a known bad jpg file it halts with a VB           Runtime Error 481 'Invalid Picture"

    How come the statement On Error GoTo ErrorThumb1 isn't trapping this error
    and processing it? 
     
    It halts right on the line:
    Thumb(1).Picture = LoadPicture(Filename1)  with the runtime error. 
     
    The frmDialog in the error handler never gets called so it never makes it this
    far.

    Any suggestions??

    Thanks much!

    Don
  •  28 Feb 2004, 1:43 PM 4595 in reply to 4594

    RE: Cannot Trap Runtime error 481 Invalid Picture ?????

    Try On Error Resume Next

    Then after the LoadPicture:

    If Err.Number = 481 Then GoTo ErrorThumb1


    James
  •  19 Apr 2004, 11:26 AM 4596 in reply to 4594

    RE: Cannot Trap Runtime error 481 Invalid Picture ?????

    Are you getting the error when running it from within the IDE? If so, check your error trapping option in the Tools/Options menu. Make sure it is either set to break on Unhandled errors or break in Class modules. If it is set to break on all errors, none of your error handling will work. Good Luck
  •  23 Jan 2007, 3:31 PM 11306 in reply to 4595

    Re: RE: Cannot Trap Runtime error 481 Invalid Picture ?????

    This is correct. For some reason err 481 cannot be handled with a simple "on error resume next" statement. It needs to go to a routine and then returned be back to code. Note: it only causes problem with the complied program, you don't see it when running with the VB interpreter.

      • sub
      •  on error goto myerror
      •   (loadpicture)
      •  on error goto 0
      • exit sub
      • myerror:
      •   if err.number=481
      •    'do nothing
      •   end if
      • resume next
View as RSS news feed in XML