Reputation: 141
I tried to use the code:
Private Sub SpaceInvadersControlButton_MouseDown (ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SpaceInvadersControlButton.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right then
Me.close
ElseIf e.Button = Windows.Forms.MouseButtons.Left then
Me.Location.X = MousePosition.X
Me.Location.Y = MousePosition.Y
End If
End Sub
However the two lines after the "ElseIf" statement give me this error:
Expression is a value and therefore cannot be the target of an assignment.
How would I do this without it erroring?
Upvotes: 0
Views: 1346
Reputation: 14002
You cannot set the X and Y of a co-ordinate individually. Try setting them together;
Private Sub SpaceInvadersControlButton_MouseDown (ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SpaceInvadersControlButton.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right then
Me.close
ElseIf e.Button = Windows.Forms.MouseButtons.Left then
Me.Location = MousePosition
End If
End Sub
Upvotes: 1