'past this in your form1 (general) (declarations)
Public Class Form1
Private mouseOffset As Point
Private isMouseDown As Boolean = False
Private Sub Label1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDoubleClick
ColorDialog1.ShowDialog()
Label1.ForeColor = ColorDialog1.Color
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseDown
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = MouseButtons.Left Then
xOffset = -e.X - SystemInformation.FrameBorderSize.Width
yOffset = -e.Y - SystemInformation.CaptionHeight - _
SystemInformation.FrameBorderSize.Height
mouseOffset = New Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If isMouseDown Then
Dim mousePos As Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseUp
' Changes the isMouseDown field so that the form does
' not move unless the user is pressing the left mouse button.
If e.Button = MouseButtons.Left Then
isMouseDown = False
End If
End Sub
end class