Computer Science Canada VB freezes! |
Author: | tupac [ Fri Feb 17, 2006 5:51 pm ] |
Post subject: | VB freezes! |
i got this problem when i try running my pong game i just started. This is the code: <the form includes a cirlce between 2 lines> 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! |
Author: | cool dude [ Sat Feb 18, 2006 12:52 pm ] | ||
Post subject: | |||
its called a timer. take away the do loop and put this
in your timer. don't forget to put an interval in the properties section for your timer |
Author: | HazySmoke)345 [ Tue Feb 21, 2006 8:17 pm ] | ||
Post subject: | |||
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.
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. |