Problem with a loop
Within a mousemove event I have, I have a loop that continues to run if the user is holding the
mouse down. Here is the code:
The problem is when the user lets go of the mouse and the control finally reaches the End Sub line,
Private Sub picAlien1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error GoTo ExitSub
If MouseDown Then
Do While MouseDown
Dim i As Integer
ScreenToClient hwnd, Mouse
If Mouse.X Mod 10 = 0 Then .left = Mouse.X
If Mouse.Y Mod 10 = 0 Then .top = Mouse.Y
For i = 0 To UBound(Alien1, 1)
If Alien1(i).index = index - 1 Then
Alien1(i).X = .left
Alien1(i).Y = .top
Properties.SetProperties .left, .top, 1, index - 1
ExitSub: End Sub
the control goes back to the end of the loop, yet the mousedown boolean is still equal to false.
I have tried to comment the line of code that tell the program what to do when an error occurs, I've
commented the line of code between the end of the Loop and the End If(this would be the with block) and
I am out of ideas, any help would be appreciated, thanks.
Edit: Figured out problem, it seems that the mousemove event kept calling itself, although I didn't see it happen
in code so in the end the program would read the line of code that it was on before the doevents command however
many times mousemove called itself. Fixed this with a boolean that tells the program if the program is already inside of the loop.
Last edited by salvinger; 05-07-2005 at 08:03 PM.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center