Public Class Form1
Inherits System.Windows.Forms.form
Private mouse_offset as point
PRIVATE SUB FORM1_MOUSEDOWN (Byval Sender As Object, _
Byval e as system.windows.Forms.MouseEventArgs) Handles mybase.mousedown
Mouse_offset = New Point (E.x, E.Y)
End Sub
PRIVATE SUB FORM1_MOUSEMOVE (Byval Sender as system.object, _
Byval e as system.windows.forms.mouseeventargs) Handles mybase.mousemove
'Press and hold the left and right keys and drag the form.
If E.Button = MouseButtons.Left or E.Button = MouseButtons.right THEN
Dim mousepos as point = sender.findform (). MousePosition
'Get mouse offset
MousePos.offset (-Mouse_offset.x, -mouse_offset.y)
'Setting the form to move with the mouse
Sender.findform (). Location = mousepos
END IF
End Sub
Private sub btnexit_click (Byval Sender as system.object, _
Byval e as system.eventargs) Handles Button1.click
'Close the form
Me.close ()
End Sub
END CLASS