KthProg wrote:I use gotos all the time in VBA and I've never had an issue with them. They are extremely useful.
Also...jesus too many comments lol.
I'm still learning c++ at this point myself.
KthProg wrote:Well, they're dangerous in extremely large projects, because it's difficult to see the flow of the program.
But when the code compiles down, it has to use gotos at the the assembly level, from what I know.
KthProg wrote:But it does save space sometimes. Also, in VBA, they're the only means of error catching.
It's actually very efficient to do things this way.
You use a statement like this at the beginning of a piece of code.
On Error Goto errorCatcher
then later you do this...
If Err.Number = someerrornumberofimportance or Err.Number = someotherimportanterrornumber then
Do error catching routine.
this allows you to consolidate all of your error catching at the end of the program, and if the error catching fails, it will continue wherever you place the errorCatcher label. It also allows you to create a different, separate, easily readable routine for each error type. You could also use flags to tell where in the code the error is coming from, if you only want to catch it if it occurs in a certain block.
I think they should at least be used in situations like this, where you don't need error catching for a specific statement, but rather for a specific error.
Users browsing this forum: No registered users and 0 guests