|
-
Sep 20th, 2010, 08:58 PM
#1
Thread Starter
Addicted Member
[RESOLVED] XY coords from Mouse click
I am working with a PictureBox and trying to click on the picture and OnClick i want to capture XY coord from the cursor.
I am using the following code
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
Dim X As Long
Dim Y As Long
Text1.Text = Text1.Text & X & " "
Text2.Text = Text2.Text & Y & " "
End Sub
The issue i have is that no matter where i click on the picturebox it returns a 0 for both the X and Y coordinates.
I read something somewhere about seting the Scale to Pixel but that doesnt seem to be working for me.
Any help would be greatly appreciated.
-
Sep 20th, 2010, 09:26 PM
#2
Thread Starter
Addicted Member
Re: XY coords from Mouse click
Nvm i got it working now.
Ty for looking
-
Sep 21st, 2010, 06:41 AM
#3
Re: XY coords from Mouse click
The problem is: in your code you are not assigning any values to the variables. You simply define them and display them without assigning any values.
vb Code:
Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
Debug.Print(e.X) '~~~ X position
Debug.Print(e.Y) '~~~ Y position
End Sub
If the problem is sorted out, it is better to mark the thread as RESOLVED. In that way, others would be able to know that your problem is sorted out. 
Good luck..
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|