English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In a MouseDown event handler, how would I store the coordinates of the point where the mouse is clicked?

2007-10-05 13:07:56 · 2 answers · asked by popngirl_14 2 in Computers & Internet Programming & Design

2 answers

Previous response isn't quite right if you need the coordinates in another section of code or in subsequent calls

remember that variables dimensioned within a sub or function have scope within that function and will be destroyed upon exiting the sub/function unless the STATIC modifier is used or you define a module level variable to store your x and y values at the beginning of the document.

Also the "e" object should be referenced (VB.net)

Private m_myY as integer 'module level variable

Mouse down event handler:
DIM STATIC myX as Integer

myX = e.X
m_myY = e.Y

2007-10-05 16:56:56 · answer #1 · answered by MarkG 7 · 0 0

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim xx , yy as integer
' xx and yy are the variables that you will use to save the value of x y coordinates.
xx=x
yy=y

End Sub

2007-10-05 23:16:49 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers