mark 发表于 2006-10-16 14:06:17

调试错误(参数不正确)

让我看看我是否能解释这个。我有一个函数;
Public Function PointTest(Pt As Long) As Boolean
   
    If getCivilObjects = False Then
      Exit Function
    End If
   
    Dim oPoint As AeccPoint
   
    Set oPoint = AllPoints.Find(Pt)if oPoint is nothing then exit function

您可以使用以下内容:
if oPoint is nothing then goto ExitHere

当发生错误时调用例程的最后一部分:
ErrorHandler:
        select case Err.number
        case -22222 '<-This would be where the error that is thrown from the .Find method
                resume next 'resume on the line following where the error was thrown
        case else
                msgbox "Something just happened... " & err.number
        end select
       
        resume ExitHere
end function

当发生错误时,遵循“On Error Goto ErrorHandler”,程序立即在“ErrorHandler”标签之后的行上继续执行。在这种情况下,选择语句。您感兴趣的是捕获查找方法生成的错误。这就是为什么我有“case-2222”,我不知道抛出了什么错误号。而不是-2222,您会输入生成的错误号。下一行“继续下一步”告诉程序立即跳回到通过错误的行之后的行。
这有意义吗?如果您需要更好的解释,请告诉我,我今晚会看看我能做些什么。

mark 发表于 2006-10-16 14:22:33


是的,非常感谢!
页: [1]
查看完整版本: 调试错误(参数不正确)