使用窗口的click事件,使用button 的move事件,加上楼上的边界判断就ok了

解决方案 »

  1.   

    定时(控制快慢)改变button的left或right
    定时用timer
      

  2.   

    Private Sub Command1_Click()
    Timer1.Enabled = True
    If Command1.Caption = "Left" Then Command1.Caption = "Right": Exit Sub
    If Command1.Caption = "Right" Then Command1.Caption = "Left": Exit Sub
    End Sub
    Private Sub Form_Load()
    Command1.Caption = "Left"
    End Sub
    Private Sub Timer1_Timer()
    With Command1
       If .Left > 25 And .Caption = "Right" Then .Left = .Left - 5
       If .Left < Form1.Width - .Width - 100 And .Caption = "Left" Then .Left = .Left + 5
       If .Left <= 25 Or .Left > Form1.Width - .Width Then Timer1.Enabled = False: Exit Sub
    End With
    End Sub
    试试
      

  3.   

    你改成form的click事件就ok了。