Code
Option Explicit
Dim cmdPressed As Boolean
Dim cmdX As Single, cmdY As Single
Private Sub Form_Load()
ScaleMode = vbTwips
End Sub
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
cmdPressed = True
cmdX = X
cmdY = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If cmdPressed Then
Command1.Move Command1.Left + (X - cmdX), Command1.Top + (Y - cmdY)
DoEvents
End If
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
cmdPressed = False
End Sub
Если ScaleMode формы неудобно держать в твипах, нужно добавить коэффициенты, например, для vbPixels:
Code
Command1.Move Command1.Left + (X - cmdX) / Screen.TwipsPerPixelX, _
Command1.Top + (Y - cmdY) / Screen.TwipsPerPixelY