Hi @eric.frissell26WKQ,
The problem with using On Error Resume Next (OERN) on it's own, is that is can hide errors and make debugging a terror when the code just doesn't work, but it doesn't tell us it didn't work because the OERN is silencing the errors.
I still do it from time to time, but it's generally considered poor practice.
If you are going to use it, it should be used with a proper error catch. You can Google "VBA error handlers" and find a bunch of info on that.
The other thing to know is that you can not use OERN in the same code as Try/Catch statements. And Try/Catch statements are really useful.
With all of that said. I did mix a lot of syntactical try/catch stuff in my previous reply, so let me see if I can clear things up.
These 4 do the same thing:
1) This one catches and handles the error separately from the remedy action, which is in the Finally.
Try 'try to get the value
otest = Parameter(oParamName)
Catch 'catch the error when the param isn't found
MsgBox("Param not found")
Finally
Call CheckOrCreateParam(oParamName)
End Try
2) This one catches and handles the error in step with the remedy action.
Try 'try to get the value
otest = Parameter(oParamName)
Catch 'catch the error when the param isn't found
MsgBox("Param not found")
Call CheckOrCreateParam(oParamName)
End Try
3) This one catches and handles the error in step with the remedy action, but all in one line.
Try: otest = Parameter(oParamName): Catch: MsgBox("Param not found"): Call CheckOrCreateParam(oParamName): End Try
4) this one is doing the same thing, but is just using the colons to combine the Catch and End Try lines
Try: otest = Parameter(oParamName)
Catch: MsgBox("Param not found"): Call CheckOrCreateParam(oParamName):End Try
Or if no message box is needed, we could do this:
Try 'try to get the value
otest = Parameter(oParamName)
Catch 'catch the error when the param isn't found
Call CheckOrCreateParam(oParamName)
End Try
or this one liner does the same as the last one:
Try: otest = Parameter(oParamName): Catch: Call CheckOrCreateParam(oParamName): End Try
Typically though you'll see this:
Try
' do something here
Catch
'catch the error when the something didn't work
End Try
Note too that you can catch the error message and hand that back to the user like this:
Try
' do something here
Catch ex As Exception
'catch the error when the something didn't work
Messagebox(ex.Message)
Finally
'do the remedy for the something that didn't work
End Try
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com