我遇到的一个严重的场景,完全让我的脚本有问题,如下所示:
On Error Resume Next
For IndexSearch = 0 To ArrayListTaskDetails.Count - 1 Step 4
If ArrayListTaskDetails(IndexSearch + 5) <> "" Then
ArrayListTaskDetails(IndexSearch + 2) = ArrayListTaskDetails(IndexSearch + 5)
'Else
'ArrayListTaskDetails(IndexSearch + 2) = DicForProcessEndDate.Item(ob9.Cells(RowCount,1))
End If
Next
If Err Then
Err.Clear
MsgBox(IndexSearch) '4
ArrayListTaskDetails(IndexSearch + 2) = DicForProcessEndDate.Item(ob9.Cells(RowCount,1))
MsgBox(ob9.Cells(RowCount,1)) '47166954
MsgBox(DicForProcessEndDate.Item(47166954)) ' here i am getting its value
MsgBox(DicForProcessEndDate.Item(ob9.Cells(RowCount,1))) ' here i didn't see any value for the key ob9.Cells(RowCount,1). Even "47166954" and ob9.Cells(RowCount,1) are same
End If
On Error GoTo 0
你能帮我理解问题是什么吗?如果这确实是一个问题,并通过更改此处的方法来帮助我解决它。
编辑
当Array out of range从该行发生错误时,If ArrayListTaskDetails(IndexSearch + 5) <> ""控制转到错误处理部分,这很完美,但IndexSearch计数增加了4. 可以说当IndexSearch= 0 时,然后引发异常,并且在 Exception 块中我得到了IndexSearch价值,而4不是,0- 为什么会这样?请告诉我!