Question

I'm currently maintaining a legacy Visual Basic project that has these "procErr:" statements all over the place. My guess is, that they are used as a way to handle if any error occurred while executing the function, is this correct?

I've converted the project to VB.NET. Would a better way not be, instead of using this procErr syntax, to wrap it inside a Try Catch instead?

Was it helpful?

Solution

My VB is a bit rusty, but I believe 'ProcErr' is not a reserved keyword. It is just a naming convention in VB to indicate the block that should be executed when an error occurs in your method (or 'procedure', hence the name).

In the actual code, you then have statements like On Error GoTo ProcErr and then you define the procerr block:

procErr:
msgbox "an error has happened"

You could replace this with any other name. In VB.NET you would indeed replace this with a try catch routine:

Try
// code
Catch x As Type
// exceoption handling
Finally
End Try 'cleanup code
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top