首先你在窗体上添加三个按钮,一个文字标签,一个timer控件
代码麻烦了点,希望能帮到你...
Dim c As Double
Private Sub Command1_Click()
'这是手动按钮
Dim a As Double
Dim b As Double
Form1.ScaleWidth = Form1.Width
Form1.ScaleHeight = Form1.Height
b = Label1.Left + Label1.Width
If c > 1 Then
If b < Form1.ScaleWidth Then
Label1.Left = Label1.Left + 100
Else
Label1.Left = Label1.Left - 100
c = c - 1
End If
Else
Label1.Left = Label1.Left - 100
If Label1.Left < 0 Then
Label1.Left = Label1.Left + 100
c = c + 1
End If
End If
End Sub
Private Sub Command2_Click()
'这是自动按钮
Timer1.Enabled = True
Dim a As Double
Dim b As Double
Form1.ScaleWidth = Form1.Width
Form1.ScaleHeight = Form1.Height
b = Label1.Left + Label1.Width
If c > 1 Then
If b < Form1.ScaleWidth Then
Label1.Left = Label1.Left + 100
Else
Label1.Left = Label1.Left - 100
c = c - 1
End If
Else
Label1.Left = Label1.Left - 100
If Label1.Left < 0 Then
Label1.Left = Label1.Left + 100
c = c + 1
End If
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Label1.Caption = "欢迎使用"
c = 2
End Sub
Private Sub Timer1_Timer()
If Command2.Value = True Then
Command3.Value = True
Else
Command2.Value = True
End If
End Sub