A Boolean expression can test more than one condition using AND and OR to combine two or more expressions. Let's suppose that we want to know if the mouse is in the top left corner. The following code (in Form1_MouseMove) would do that:
If e.X = 0 And e.Y = 0 Then
Me.Text = "Top left corner"
End If
We could also define the top left corner as a slightly bigger area and say;
If e.X < 10 And e.Y < 10 Then
Me.Text = "Top left corner"
End If
For some reason, we can never get the value of e.X to equal me.Width. When the form has a width of 300, the largest value that appears for e.X is 283. Therefore, if we want to know if the mouse is in the top right corner, we could use the code below:
If e.X >= Me.Width - 20 And e.Y < 10 Then
Me.Text = "Top right corner"
End If
If we would like to know if the mouse is along either side, left or right we could write:
If e.X < 10 Or e.X >= Me.Width - 20 Then
Me.Text = "side"
End If
We can also add the Else block to say middle if it is not on the side:
If e.X < 10 Or e.X >= Me.Width - 20 Then 'left or right
Me.Text = "side"
Else
Me.Text = "middle"
End If