?
Solved

Trap and continue in Loop..

Posted on 2002-04-05
9
Medium Priority
?
164 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

752 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