rjamison
14 years agoOccasional Contributor
Problems with Error Trapping the 'Set' command
I have a web page that changes the locations of items using CSS and DIVs. This is conditional, so it makes it difficult to know which panel index to do the 'Set' on. I tried to trap the error with the following code:
===========================================
Err.Clear
On Error Resume Next
Set OrderNumtxt = panel.Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(0) _
.Panel(1).Panel(1).Panel(0).Panel("HN_OR_OrderSummary") _
.Panel("orderSummaryZone").Panel(0).Panel(1).Panel(0)
If Err.Number <> 0 Then
x = 1
Else
x = 0
End If
msgbox(x)
' x shows up as 0 here when the 'Set' in the 3rd line fails.
if x = 0 then
Set OrderNumtxt = panel.Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(0) _
.Panel(2).Panel(1).Panel(0).Panel("HN_OR_OrderSummary") _
.Panel("orderSummaryZone").Panel(0).Panel(1).Panel(0)
end if
' This one 'Set's correctly and I can now assign a value to OrderNum
OrderNum = mid(OrderNumtxt.innerText, 15, 13)
===========================================
My test script reports errors on the first 'Set' attempt, but I need to suppress the error count. Can anyone help out on this?
Thanks.
===========================================
Err.Clear
On Error Resume Next
Set OrderNumtxt = panel.Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(0) _
.Panel(1).Panel(1).Panel(0).Panel("HN_OR_OrderSummary") _
.Panel("orderSummaryZone").Panel(0).Panel(1).Panel(0)
If Err.Number <> 0 Then
x = 1
Else
x = 0
End If
msgbox(x)
' x shows up as 0 here when the 'Set' in the 3rd line fails.
if x = 0 then
Set OrderNumtxt = panel.Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(1).Panel(0) _
.Panel(2).Panel(1).Panel(0).Panel("HN_OR_OrderSummary") _
.Panel("orderSummaryZone").Panel(0).Panel(1).Panel(0)
end if
' This one 'Set's correctly and I can now assign a value to OrderNum
OrderNum = mid(OrderNumtxt.innerText, 15, 13)
===========================================
My test script reports errors on the first 'Set' attempt, but I need to suppress the error count. Can anyone help out on this?
Thanks.