新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim rval, x, y, z As Long
Form1.AutoRedraw = True
x = 5: y = 5
For z = 1 To 50
rval = MoveWindow(Form1.hwnd, x, y, 100, 100, 1)
Sleep 100
x = x + 5: y = y + 5
Next z
For z = 1 To 50
rval = MoveWindow(Form1.hwnd, x, y, 100, 100, 1)
Sleep 100
x = x + 5: y = y - 5
Next z
End
End Sub