Start a new project named XY. For this project you do not need any controls.
Double click on the form. This will open the code view window with Form1 selected as the object in the drop down window on the left and Load selected as the event on the right. (The load event is the default when you double click the form to open code view.)
In the drop down box on the right select the MouseMove event. You will have both events visible with no code in either.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
End Sub
End Class
Notice that the type for e in Form1_Load is System.EventArgs, but the type for e in Form1_MouseMove is System.Windows.Forms.MouseEventArgs.
Remember that e always has information about the event that occurred. In the MouseMove event, the properties in e include the X and Y coordinates of the mouse.
Write the code for Form1_Mouse_Move as shown below:
Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Me.Text = e.X
End Sub
Run the program and notice the values that appear in the title. X is the distance from the left edge starting with 0. Y is the distance from the top starting with 0.