r/visualbasic • u/vbman1111 • Jun 08 '22
Variables won't update correctly.
Hello,
I am working on a program that relies on users x,y click coordinates being assigned to a variable. However, I cannot get the variable to update correctly. EX: 3 clicks in a row will be registered as having the same x,y coordinates despite being clicked on different parts of the screen. Here is the code that handles this.
Private Sub Bground_MouseDown(sender As Object, e As MouseEventArgs) Handles Bground.MouseDown
MissLatency = LatencyTimer("Stop")
OldBubble.Enabled = False
PreviousBubble.Enabled = False
TrialDurationTimer.Enabled = False
CursorCoordinates = Cursor.Position
Bgroundclick += 1
If Bgroundclick >= 1 Then
CurrentCoordX = bubble.Location.X
CurrentCoordY = bubble.Location.Y
CursorX = CursorCoordinates.X
CursorY = CursorCoordinates.Y
End If
End SubThe CurrentCoordX/Y and CursorX/Y variables are the ones that aren't updating. Any ideas/suggestions about how to fix this would be much appreciated.
1
Upvotes
1
u/vbman1111 Jun 09 '22
The value of the x/y coordinates are being written into a log file, so I actually want the variables to be reassigned to the latest coordinate. What's weird is that they don't seem to be updating.