TheSwamp

Code Red => VB(A) => Topic started by: rude dog on April 09, 2008, 05:03:45 PM

Title: Exit Properly?
Post by: rude dog on April 09, 2008, 05:03:45 PM
How do  get this piece of to exit smoothly without bombing out if the user selects a point out in space or right clicks?

Code: [Select]
Public Sub GetEntExample()

 Dim returnObj As AcadObject
    Dim basePnt As Variant
   
    On Error Resume Next
   
    ' The following example waits for a selection from the user
RETRY:
    ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an object"
   
    If Err <> 0 Then
        Err.Clear
        MsgBox "Program ended.", , "GetEntity Example"
        Exit Sub
    Else
        returnObj.Update
        MsgBox "The object type is: " & returnObj.EntityName, , "GetEntity Example"
        returnObj.Update
    End If
   
    GoTo RETRY
End Sub

Title: Re: Exit Properly?
Post by: David Hall on April 09, 2008, 06:00:25 PM
what exactly are you referring to?  It did exactly what I expected it to
Title: Re: Exit Properly?
Post by: David Hall on April 09, 2008, 06:01:28 PM
I guess what I mean is do you want to avoid the Program ended msgbox or do you want it to say "You missed picking something, try again" or what ?
Title: Re: Exit Properly?
Post by: Bryco on April 09, 2008, 06:05:28 PM
Start with a better getentity http://www.theswamp.org/index.php?topic=9301.msg119833#msg119833 (http://www.theswamp.org/index.php?topic=9301.msg119833#msg119833)
Title: Re: Exit Properly?
Post by: rude dog on April 09, 2008, 07:29:30 PM
At Lunch time today it wasnt working properly I had about 4 or 5 different versions up  :oops:
This one does work though
Thanks for the other thread as well looks very useful.
Title: Re: Exit Properly?
Post by: rude dog on April 10, 2008, 11:36:19 AM
Found out what the problem was @ work
In the Tools --> Options box in the VBA IDE I had the box checked that said "Break on all Errors"
when it should have been set up to break on Unhandled errors.
Thanks