Dim mx As Integer, my As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mx = X
my = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Form1.Move Me.Left + (X - mx), Me.Top + (Y - my)
End If
End Sub
很简单:使用一个全局变量记录按下鼠标右键时的坐标(mx,my),然后当Button变量值是2(左键是1,右键是2)的时候,利用Move来计算鼠标移动并同时移动窗体。