Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

End Command in a loop

End Command in a loop

Anonymous
Not applicable
608 Views
3 Replies
Message 1 of 4

End Command in a loop

Anonymous
Not applicable
Hello,

Im new on VBA, so please bear with me. What I'm trying to do is to be able
to end a command when desired. Right now I have a GoTo estatement to
repeat a process where is going to keep asking me for selection of objects
and some input information. How can I have the user to stop this Loop when
is desired to end the command?
An example below is ilustrated. Help would be appreciated.

Line1:
pnt = ThisDrawing.Utility.GetPoint(, "Select Point on Surface: ")
srfelev = oSurf.FindElevationAtXY(pnt(0), pnt(1))
Dim overt As Integer
ofet.Elevation = srfelev + eldif
GoTo Line1

How to end this process?
0 Likes
609 Views
3 Replies
Replies (3)
Message 2 of 4

Hallex
Advisor
Advisor
I like this nice code:

{code}
'' written by Tony Tanzillo
'' request check "Break on Unhandled Errors" in General options
Public Sub LoopExample()
Dim Msg As String
Msg = vbCrLf & "First point: "
Dim MyPoint As Variant
Do
On Error Resume Next
MyPoint = ThisDrawing.Utility.GetPoint(, Msg)
If Err Then
Err.Clear
Exit Do
End If
On Error GoTo 0

' Process the entered point here:
ThisDrawing.ModelSpace.AddCircle MyPoint, 10#
Msg = vbCrLf & "Next point or ENTER to exit: "
Loop
On Error GoTo 0

End Sub
{code}

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks so much
wrote in message news:[email protected]...
I like this nice code:

{code}
'' written by Tony Tanzillo
'' request check "Break on Unhandled Errors" in General options
Public Sub LoopExample()
Dim Msg As String
Msg = vbCrLf & "First point: "
Dim MyPoint As Variant
Do
On Error Resume Next
MyPoint = ThisDrawing.Utility.GetPoint(, Msg)
If Err Then
Err.Clear
Exit Do
End If
On Error GoTo 0

' Process the entered point here:
ThisDrawing.ModelSpace.AddCircle MyPoint, 10#
Msg = vbCrLf & "Next point or ENTER to exit: "
Loop
On Error GoTo 0

End Sub
{code}

~'J'~
0 Likes
Message 4 of 4

Hallex
Advisor
Advisor
You're welcome
And thanks to Tony Tanzillo 🙂

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes