Concatenation

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:

Private Sub Form1_MouseMove(ByVal sender As Object, _
      ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
  Me.Text = e.X & "," & e.Y
End Sub

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?

movemouse

A 5,20

B 15,0

C 0,45

D 25,30

E 35,10

F 40,40 (the current mouse position)

G 45,25

Experiment: Write other procedures that display other information about an event. Try different events, and display different properties of e.
INDEX, The Code View, Selecting code from list, Events, Arguments, Concatenation, Sender, Scroll Bars, Decimal Values on Scroll Bar, Picture Boxes: the Seasons, Comments, Printing, Closing
Next lesson: Functions in Visual Basic

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Concatenation