There are no try/catch blocks in VB. I wish there was. VB.Net has them.
In VB, you use On Error. There are several ways to use it.
On Error Resume Next ' This will ignore errors and continue
On Error Goto LineLabel ' This will jump you to error handler
On Error Goto 0 ' This will turn off error handling
The best way (in my opinion) to use error handling is....
Code:
Public Sub ErrorHandlingExample()
On Error Goto ErrorHandler
Dim iTest as Integer
iTest = iTest / 0
Exit Sub
ErrorHandler:
Call MsgBox(Err.Description)
End Sub
This is a brief description, you should look at the help files more a fuller understanding of error handling.
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
You might also check out the FAQ section of the forum, for example faq222-1694
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.