
-----------------------------------
tupac
Fri Feb 17, 2006 5:51 pm

VB freezes!
-----------------------------------
i got this problem when i try running my pong game i just started. This is the code: 
Private Sub Form_Load()
Dim dx As Integer
Dim dy As Integer
dx = 5
dy = 5
do
Shape1.Top = Shape1.Top + dx
Shape1.Left = Shape1.Left + dy
loop
end sub

thats the code... i duno wats wrong, cuz if i dont use "do" to loop the program, the circle wont keep traveling the path I gave it... :? 
PLZ help!

-----------------------------------
cool dude
Sat Feb 18, 2006 12:52 pm


-----------------------------------
its called a timer. take away the do loop and put this


Shape1.Top = Shape1.Top + dx 
Shape1.Left = Shape1.Left + dy 


in your timer. don't forget to put an interval in the properties section for your timer

-----------------------------------
HazySmoke)345
Tue Feb 21, 2006 8:17 pm


-----------------------------------
The problem is that there is no condition after "do" or "loop", which means, you're asking the computer to do what's between "do" and "loop" forever. There are two ways to solve that problem. One, is like what the person before me said... make a timer... the other one is something like this.
Do 
Shape1.Top = Shape1.Top + dx 
Shape1.Left = Shape1.Left + dy 
DoEvents
Loop 


What "DoEvents" does is that it makes the form refresh, in another word, unfreeze itself, but it's not as realiable as a timer, the speed will vary depends on how busy your computer is, but try it out.
