Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ErrHandler not catching multiple Errs?

Status
Not open for further replies.

nulll

Programmer
Dec 8, 2001
6
0
0
US
I'm werking on a site-checker project that checks to see if certain sites contains certain material using the Inet control. I've come across a little problem in one of my subs that handles the actual checking of the sites using the Inet.openURL method.

Now this is where I'm running into my problem...
When a site in my listbox is not found, it usually tries to find it till it times out(err.number = 35761).

I set up an error handler and it finds any first error(timeout [#35761]) that accures and just disregards it via the handler, but any other timeouts after the first cause a fatal error and the program to crash.

Why would the handler werk for the first timeout error but not the second? Keep in mind... I know my code(select case and other) is not complete, but by the looks of it, the code should run through without problems. What am I forgeting??

Thanks,
null

Private Sub cmdSearchAll_Click()
Dim SiteCount As Integer, strData As String, CheckSite As String
Dim URL1 As String, URL2 As String
On Error GoTo ErrHandler

If frmMain.lstCheckList.ListCount = 0 Then
MsgBox "There are no sites queued to search." & Chr(13) & "Add at least one site to your Site Check List before preceding.", vbExclamation, "No Sites Found"
Exit Sub
End If

UserStop = False
cmdStop.Enabled = True
lblLFound.Enabled = True
lblLFoundX.Enabled = True
lblLNFound.Enabled = True
lblLNFoundX.Enabled = True
lblSiteErrs.Enabled = True
lblSiteErrsX.Enabled = True


URL1 = txtURL.Text


For SiteCount = 0 To lstCheckList.ListCount - 1
BackFromErr:
strData$ = ""
DoEvents
If UserStop = True Then GoTo Endit
CheckSite$ = LCase(lstCheckList.List(SiteCount))
StatusBar1.Panels(2).Text = "Checking " & CheckSite$
StatusBar1.Panels(3).Text = SiteCount + 1 & " of " & lstCheckList.ListCount
Inet1.Cancel ' Stops any current operations
strData = Inet1.OpenURL(CheckSite$, icString)
strData$ = ClearSpaces(strData$)
strData$ = Replace(strData$, """", "")
Next SiteCount

On Error GoTo 0

Endit:
Inet1.Cancel
cmdStop.Enabled = False
StatusBar1.Panels(2).Text = "Finished"
Exit Sub


ErrHandler:
Select Case Err.Number
Case 35761
MsgBox "An error happened here!" & vbCrLf & _
"Error number: " & Err.Number & vbCrLf & _
"Error Description" & Err.Description & vbCrLf & _
"Error Help Context ID" & Err.HelpContext & vbCrLf & _
"Error Help File" & Err.HelpFile, vbCritical, "ERROR MESSAGE"
Err.Clear ' destroy the error and…

Case Else ' if you get any other error code do this
MsgBox "An error happened here!" & vbCrLf & _
"Error number: " & Err.Number & vbCrLf & _
"Error Description" & Err.Description & vbCrLf & _
"Error Help Context ID" & Err.HelpContext & vbCrLf & _
"Error Help File" & Err.HelpFile, vbCritical, "ERROR MESSAGE"
Err.Clear ' destroy the error and…

End Select

Inet1.Cancel
SiteCount = SiteCount + 1
lblSiteErrsX.Caption = lblSiteErrsX.Caption + 1
GoTo BackFromErr

End Sub
 
I was just looking through some error handling pages and I got another question.

This could be part of the source of my problem, but i'm not sure...

At the end of my errhandlers, I use sitecount = sitecount+1, which is to somewhat 'resume' to the next for cycle when I use GoTo BackFromErr.

Would it be a better idea to just take out both the blah = blah + 1 and the GoTo BackFromErr and just replace them with 'Resume Next'?

-null
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top