Solved

Trap and continue in Loop..

Posted on 2002-04-05
9
162 Views
Last Modified: 2012-05-04
I have a routine that thumbnails an entire directory.
The problem is animated gifs or unsupported file types.
I cannot get this loop to continue if it bombs because of an err.number 481....
There has to be a way to increment and continue onto the next file...I have tried everything I can think of...

Public Sub SaveWholeFolder(sType As String)
For i& = 0 To frmDemo.List1.ListCount - 1
  fName$ = frmDemo.List1.List(i&)
  'On Error do what?
  frmDemo.picHidden.Picture = LoadPicture(fName$)
  Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
  frmDemo.Caption = i&
  DoEvents
  x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
  xx$ = Mid(x$, 1, InStr(x$, "."))
  xx$ = xx$ & sType
  Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)
Next i&

End Sub

Thanks
0
Comment
Question by:Form_Glow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Expert Comment

by:rkot2000
ID: 6920997
on error resume next


atfer the line with possible error

if err.numnber <>0 then
  log this error
  err.clear
end if
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6920998
wouldn't something like this work?

Public Sub SaveWholeFolder(sType As String)
For i& = 0 To frmDemo.List1.ListCount - 1
 fName$ = frmDemo.List1.List(i&)
 On Error GoTo SkipMe
 frmDemo.picHidden.Picture = LoadPicture(fName$)
 Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
 frmDemo.Caption = i&
 DoEvents
 x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
 xx$ = Mid(x$, 1, InStr(x$, "."))
 xx$ = xx$ & sType
 Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)

 SkipMe:

Next i&

End Sub

0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 100 total points
ID: 6921045
full solution :

Public Sub SaveWholeFolder(sType As String)
On Error resume next
For i& = 0 To frmDemo.List1.ListCount - 1
 fName$ = frmDemo.List1.List(i&)
 frmDemo.picHidden.Picture = LoadPicture(fName$)
     if err.number = 0 then
          Call StretchPic(frmDemo.picHidden, frmDemo.picMain)
           frmDemo.Caption = i&
           DoEvents
           x$ = Mid(fName$, InStrRev(fName$, "\") + 1)
           xx$ = Mid(x$, 1, InStr(x$, "."))
           xx$ = xx$ & sType
           Call SavePicture(frmDemo.picMain, App.path & "\Thumbnails\" & xx$)
     else
          err.clear
     end if    
Next i&

End Sub
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 1

Author Comment

by:Form_Glow
ID: 6921076
Still bombs out at the first ani...tried all 3 solutions.........
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6921119
check you tools-options-general tab - error trapping should be set to break in class module
0
 
LVL 15

Expert Comment

by:ameba
ID: 6921125
or "Break on Unhandled Errors"
0
 
LVL 1

Author Comment

by:Form_Glow
ID: 6921163
The problem appears to be (always a file) in temp internet folder....Searching the drive the file does not exist....but my FindFiles routine is finding these strange "fake" gifs....that will always make it by the error trap...and lock the app.
0
 
LVL 17
ID: 6921185
can you call out to another routine?

Private Sub Command1_Click()
Dim ix As Integer

For ix = 1 To 100
dostuff ix
Next ix

End Sub



Private Sub dostuff(ix As Integer)
On Error GoTo handler:
'simulate error condition
If ix = 50 Then Err.Raise vbObjectError + 2002, "me", "test"
'the call that would actually generate the error
List1.AddItem ix
Exit Function
handler:
End Function
0
 
LVL 15

Expert Comment

by:ameba
ID: 6921829
Ah, yes, that error...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question