Hello guys, how to track the mouse click coordinate inside the form , save it to listbox or variable. Right now i am using checkbox method which already specify the coordinate. I attach the image to illustrate my program

To capture the mouse co-ordinates, try something like -

'In a module add the following code...
Private Type POINTAPI
      x       As Long
      y       As Long
End Type

'Private Declare Function M_GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long

Public Sub GetCursorPos(xX As Long, xY As Long)
Dim pt      As POINTAPI
Call M_GetCursorPos(pt)

xX = pt.x
xY = pt.y
End Sub

To draw a line with the mouse, you can use the click events of the mouse as in -

'Enter the following code in the Form_MouseDown ( ) procedure, Form_MouseMove ( ) procedure and cmdClear_Click ( ) procedures respectively.

Private Sub cmdClear_Click()
frmDraw.Cls
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
frmDraw.CurrentX = X
frmDraw.CurrentY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Line (frmDraw.CurrentX, frmDraw.CurrentY)-(X, Y)
End If
End Sub

hiii.....
iam need a program in visual basic to draw line or polygon or any shape by mouse click and show the coordinates for each point of click , thanks

commented: A few issues. Visual Basic came in 6 versions. The last was 22 years ago so few have that today! +15
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.