Zebra0.com

visual-basic code

Concatenation means to paste together two or more strings. We will use concatenation to display the values of both X and Y in the title. In algebra the coordinates of a point are usually displayed as X,Y. Rewrite the mouse move event to display both X and Y as shown below using the concatenation operator, &, to paste together the value of X, a string literal "," and the value of Y:

Public Class Form1
    Private Sub moving(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
        Me.Text = e.X & "," & e.Y
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = "Hello World"
    End Sub
End Class

Run the program and notice the coordinates as you move the mouse. Move the mouse to the position where you can see 0,0 as the title. Move the mouse to each edge of the form and notice the coordinates.

In the screen shot below where is the mouse? What are the coordinates of each point?