>Sorry but I'm not following you.
The idea is to run an infinite loop (note the condition); interrupt if the user presses a certain key. Since this is not related to any TextBox, inkey() seems to make more sense. I have done similar things in the past, but I don't know why this particular code wouldn't work.
Mike, for an infinite loop, instead of
do while 1 = 1
you can use the simpler
do while .T.
>>I need to stop the loop after it has been clicked.
>>
>>
>>>Why not use KeyPress event ?
>>>
>>>>I’m using this code in a click method of a form and trying to get escape but the ? shows the same values regardless of what I press. I have the KeyPreview = .t.
>>>>
>>>>DO WHILE 1 = 1
>>>>
>>>> IF ctr > 50
>>>> EXIT
>>>> ENDIF
>>>>
>>>> ?INKEY(), LASTKEY(), CHRSAW()
>>>>
>>>> IF INKEY() = 27
>>>> EXIT
>>>> ENDIF
>>>>ENDDO
>>>>
>>>>
>>>>but my ? only shows 0 13 .f. regardless of what key I press
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)