I have a mousedown event that needs to iterate through a for statement. I know the way to do this is with a timer but damned if I can figure out the syntax. Here’s the MouseDown Code:
Var r As New Rect
For i As Integer = 0 To totalRows
TestLbl.Text = i.ToString
TestLbl.Refresh
MouseDownTimer.RunMode = Timer.RunModes.Single
r.Top = VDB(i,2)
r.Left = VDB(i,1)
r.Width = VDB(i,3)
r.Height = 40
If r.Contains(X,Y) Then
Exit For
MessageBox("Got It")
MouseFound = 1
Else
MouseFound = 0
End If
MouseDownTimer.RunMode = Timer.RunModes.Off
Return RectFound
Next
RectFound and MouseFound are properties to enable sharing with the Timer event.
Any help or suggestions would be greatly appreciated.
But my testing has shown me that, if I just work with a single Rect - ie, swap the VDB(i,n) for VDB(n,n) -the MouseDown works as expected but, as soon as I try to iterate, it stops. And, even though it seems to only be looking at i = 0, clicking on Rect(0) gets nothing.
Here’s the code without timer:
Var r As New Rect
For i As Integer = 0 To totalRows
r.Top = VDB(i,2)
r.Left = VDB(i,1)
r.Width = VDB(i,3)
r.Height = 40
If r.Contains(X,Y) Then
Exit For
MessageBox("Got It")
Return True
End If
Next
Thanks for the heads-up. I’ll reciew my code again. Obviously the messagebox is just for testing. Maybe I changed the order but it’s all working just dandy now.
As I say, the code I’ve written in the method must be in the correct order. Having made it work I’ve closed Xojo down for Christmas (in accordance with the “You ever want me to speak to you again?” law)
I certainly see the logic here. I was swapping stuff around like a madman, trying to get it to work.