[dba-VB] [AccessD] OT: VB.Net - general questions

jcolby at colbyconsulting.com jcolby at colbyconsulting.com
Mon Jul 14 13:16:56 CDT 2003


I am porting my SysVars class to VB.Net just as an exercise.  Of course I
use the error handler insertion wizard for Access, but VB.Net has the new
Try/catch error handling (which I very much like BTW).  But it does mean
that no port is trivial since I have to remove all the OnError / resume kind
of stuff in every function.

In my old code I have a case statement where I accumulated the various
errors that could occur, and once handled a resume next would take me back
into the code.  that obviously has to change but I'm a little confused as to
what it will change to.  For example I have code that attempts to add an
object to a collection:

	mcolObjNames.Add(strObjName, strObjName)

There could be two problems here, the first is that no collection has been
instantiated yet, the second is that the object is already in the
collection.  Thus a select case would be nice, which was how the old error
handler in Access worked.

Select case err
	case XXX
	case YYY
	Case else
end select

Now we have:

Try

	mcolObjNames.Add(strObjName, strObjName)

Catch e as XXXX (FIRST PROBLEM - WHAT IS xxxx?)
	Handle error here
Finally

End Try

It certainly looks like e could be used in a select case statement.  However
to do so I need the equivalent of the "resume next".


AND FINALLY...

In access I also used a label for the exit such that all exiting code could
go through the exit point for cleanup of pointers etc.  The books I have
don't ever show such a construct.


John W. Colby
www.colbyconsulting.com


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the dba-VB mailing list