先定义全局变量
iX, iY
Private Sub imgMoveBar_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
iX = X
iY = Y
End Sub
Private Sub imgMoveBar_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button <> xlPrimaryButton Then Exit Sub
Application.EnableEvents = False
Me.Top = Me.Top + Y - iY
Me.Left = Me.Left + X - iX
Application.EnableEvents = True
End Sub