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
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