The error or exception handling in visual basic is quite simple, here an example:
Public Sub doSomething(argument1,argument2)
On Error GoTo ErrorHandler
...
Exit Sub
ErrorHandler:
...
Resume Next
End Sub
More infos can be found here (using internet explorer recommended, that this site works properly)