Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancelling VBA Do..Loop when user presses 'Enter'..

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi,

Does anybody know how I can break a Do (while/until)...Loop when the user presses 'Enter'?..

This will be for getting multiple points from AutoCAD and the question is an extension on my previous thread about getting multiple points but I didn't want the question lost and avoided..

If got a do...loop that can get the points but I can't break out of the loop.. Here's snippet of the code....

Code:
Private Sub CommandButton7_Click()
Dim ptx() As Double  'Point array (multiple if necessary)..
Dim polyXX As AcadPolyline ' Polyline to be drawn from the points array..
Dim countx As Integer 'Counter for loop..
Dim KeyAscii As Integer 'Key press (Enter)..

areaform.hide
' Start the point pick loop..
Do While KeyAscii <> 13
' Error Test for GetPoint method..
On Error Resume Next
TryAgain:
    ptx() = ThisDrawing.Utility.GetPoint(, &quot;Pick a point. (Press 'Enter' to finish)..&quot;)
ErrHndlr:
    If Err.Number <> 0 Then
        Err.Clear
        GoTo TryAgain
    End If
    On Error GoTo ErrHndlr
countx = countx + 1  'Add 1 to the counter..
Loop  'end loop..

ReDim Preserve ptx(0 To countx - 1)  'Re-dimension the ptx() variable..
Set polyXX = ThisDrawing.ModelSpace.AddPolyline(ptx)  'Draw a polyline from the points array..
End Sub

Any ideas,

Cheers,

Renegade.. BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
+447919 117062 (mobile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top