Results 1 to 3 of 3

Thread: [RESOLVED] XY coords from Mouse click

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    230

    Resolved [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.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    230

    Re: XY coords from Mouse click

    Nvm i got it working now.

    Ty for looking

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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:
    1. Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    2.         Debug.Print(e.X)    '~~~ X position
    3.         Debug.Print(e.Y)    '~~~ Y position
    4.     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
  •  



Click Here to Expand Forum to Full Width