Her er en stump kode fra en loginform jeg har lavet, der kan du se hvordan jeg bruger en errorhandler.......
'This button logs you on the domain
Private Sub cmdVerify_Click()
'If there is an error the errorhandler catches it
On Local Error GoTo ErrorHandler
    'The text fileds where you enter your info
    vUser = txtUser.Text
    vPass = txtPass.Text
    vDomain = txtDomain.Text
    'Tells that it is a WinNT domain
    Set dso = GetObject("WinNT:")
    'Gets the variables into the ADSI and contacts the Domain Controler
    Set domain = dso.OpenDSObject("
WinNT://" & vDomain & "", "" & vUser & "", "" & vPass & "", ADS_SECURE_AUTHENTICATION)
Exit Sub
'The errorhandler catches an error and tells the user what the error is
ErrorHandler:
    If Err = -2147023570 Then MsgBox "Unknown User or Bad Password", , "Login Failure"
    If Err = -2147467259 Then MsgBox "Unknown Domain", , "Login Failure"
Exit Sub