-
I've currently have a loop of a ball bouncing around the screen, but i wanna know if thers any way u can get the loop to break if you hit escape or x. I tried to call form_keypress with in the loop to see if a key was pressed but that doesnt seem to be working. can anyone help?
-
Hi,
This may work:
dim run as boolean
--------------------
do until run = false
' ball bouncing code
loop
Private Sub Form_KeyPress(KeyAscii As Integer)
dim strKey as string
strKey = chr(keyascii)
if strKey = "x" then run = false
End Sub
-------------------
I hope it works!
-
remember to put DoEvents inside your loop, or it will hang the OS while your prog is running ;)
------------------
cintel rules :p
www.cintelsoftware.co.uk
-
Inorder for you to break a loop, you must use the function Doevents. Look this up in the help because that is the official method of breaking a loop.
-
Thank you for the help, The DoEvents worx great =)