Hi,
i want to get current position of cursor on the form.
there are label to show the coordinates of cursor position.
anyone can help me. i don't have idea for this.

thanks
Best regards.

Try this, it will return the position on the screen in pixels of the cursor :

Option Explicit
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Function GetXCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetXCursorPos = pt.X
End Function

Public Function GetYCursorPos() As Long
   Dim pt As POINTAPI
   GetCursorPos pt
   GetYCursorPos = pt.Y
End Function

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label1.Caption = "X Screen Position = " & GetXCursorPos
    Label2.Caption = "Y Screen Position =  " & GetYCursorPos
End Sub

Hope it helps.

commented: Great Help +4

Great..it run like a charm..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.