Solved

Trap and continue in Loop..

Posted on 2002-04-05
9
158 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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:Form_Glow
Comment Utility
Still bombs out at the first ani...tried all 3 solutions.........
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Expert Comment

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

Expert Comment

by:ameba
Comment Utility
or "Break on Unhandled Errors"
0
 
LVL 1

Author Comment

by:Form_Glow
Comment Utility
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
Comment Utility
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
Comment Utility
Ah, yes, that error...
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now