----------------------------------- RaLz Wed May 12, 2004 4:16 pm Some newbie help here please ----------------------------------- Hey im trying to make a game in vb and it's basically my first time trying to make on in vb. So i need some info. Right now im trying to make my character run across the screen but i have a problem if i hold down the arrow key and say i put a loop like this " Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 37 Then Do Until KeyUp = 37 char.Left = char.Left - 10 loop end if the character just zooms across the screen and crashes vb. Now i was wondering if there is some delay command like in turing to slow this process down. If you guys have any suggestions on how to make this run smoothly it would be much appreaciated. ----------------------------------- Tony Wed May 12, 2004 4:24 pm ----------------------------------- well instead of -10, you could move by a smaller incroment... such as -0.1 or you could use a system delay which in VB is called sleep Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) and is called Sleep numMilliseconds where numMilliseconds is an integer value of the delay in milliseconds ----------------------------------- RaLz Wed May 12, 2004 4:51 pm ----------------------------------- Thanks!! ----------------------------------- RaLz Wed May 12, 2004 5:05 pm ----------------------------------- umm here is my code for the moment how do i get the keyup function to work and by the way the sleep function works great. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 37 Then Do Until x = 20 char.Left = char.Left - 100 x = x + 1 Loop ElseIf KeyCode = 39 Then Do Until x = 20 char.Left = char.Left + 100 x = x + 1 Sleep (50) Loop End If End Sub I want to put do until keyup = 37 but it's not working because it sees keyup as just a variable. ----------------------------------- RaLz Wed May 12, 2004 5:31 pm ----------------------------------- Never mind i figured it out :wink: