.Message) txtPassword.Focus() Catch ex As Exception MessageBox.Show(ex.Message) Finally oUser.Dispose() oUser = Nothing End Try End Sub
The order of these exception filters is important. The more specific filters should always be defined before the generic filters. The most generic filter (ex as Exception) should always be the last filter to ensure that any unanticipated exception is caught. 异常的参数是很重要的,一些特别的参数通常要在一般的异常参数之前定义。一般的异常参数通常都放到最后以便能截住所有的不可预测异常。
Conclusion 结语 Exception handling in Visual Basic has changed, but it has only gotten better. You can now build structured exception handlers to catch any type of error or business rule violation. With Try/Catch/Finally and the ability to inherit your own exception classes from the .NET exceptions, we won''''t be missing On Error Goto! 异常处理在VB中已经起了变化,但只有变得更好。有可以组建一个异常结构去任何错误。通过Try/Catch/Finally 加上继承 .Net 异常去定义你自己的异常类,我们也许不会再想念On Error Goto了!
•Life without Control Arrays in Visual Basic .NET •Visual Basic Language Concepts: Structured Exception-Handling •Visual Basic Language Specification: Structured Exception-Handling Statements •The Visual Basic Language Newsgroup: microsoft.public.dotnet.languages.vb •Paul Vick''''s Blog (Language Designer for Visual Basic) Deborah Kurata is a software developer and the best-selling author of Doing Objects with Visual Basic 6.0. She is among the highest rated speakers at software development conferences worldwide and is the co-founder of InStep Technologies, a leading software consulting and training firm.
上一页 [1] [2] [3] |