F
fniles
In VB 6 I can do the following:
Sub MySub
on error goto Err1
: --> all my codes are here
: --> say this is where the error occurs
: --> this is where resume next will bring me after Err1
exit sub
Err1:
msgbox "error = " & error
resume next
end sub
With the above codes, when I get an error, it did not exit out of my
subroutine, instead I will go to the next statement after I get the error.
Can I do the same thing in VB.NET 2005 ? Thank you.
Currently in VB.NET, this is what I do:
Sub MySub
try
: --> all my codes are here
Catch ex As Exception
Try
swError = New StreamWriter(Application.StartupPath &
"\Log.txt", True)
swError.WriteLine(Now & " error = " & ex.Message)
swError.Close()
swError = Nothing
Catch ex2 As Exception
End Try
End Try
End Sub
With the above code, if I get an error, it will exit the sub and will not
execute the rest of the code in my subroutine.
Sub MySub
on error goto Err1
: --> all my codes are here
: --> say this is where the error occurs
: --> this is where resume next will bring me after Err1
exit sub
Err1:
msgbox "error = " & error
resume next
end sub
With the above codes, when I get an error, it did not exit out of my
subroutine, instead I will go to the next statement after I get the error.
Can I do the same thing in VB.NET 2005 ? Thank you.
Currently in VB.NET, this is what I do:
Sub MySub
try
: --> all my codes are here
Catch ex As Exception
Try
swError = New StreamWriter(Application.StartupPath &
"\Log.txt", True)
swError.WriteLine(Now & " error = " & ex.Message)
swError.Close()
swError = Nothing
Catch ex2 As Exception
End Try
End Try
End Sub
With the above code, if I get an error, it will exit the sub and will not
execute the rest of the code in my subroutine.