城市品牌营销:用VB编个简单的程序

来源:百度文库 编辑:高考问答 时间:2024/04/28 15:12:45
能让label左右不停的动
1楼的,对是对着,为什么运行它不动呀???
时间也设置了,单个运行TIMER1或TIMER2都能行

Private Sub Timer1_Timer()
Static CtrlVal As Boolean
CtrlVal = Not CtrlVal
If CtrlVal Then
Label1.Left = Label1.Left - 100
Else
Label1.Left = Label1.Left + 100
End If
End Sub

用如下代码可实现:
Option Explicit

Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 100
If Label1.Left + Label1.Width >= Form1.Width Then
Timer2.Enabled = True
Timer1.Enabled = False
End If
End Sub

Private Sub Timer2_Timer()
Label1.Left = Label1.Left - 100
If Label1.Left = 0 Then
Timer1.Enabled = True
Timer2.Enabled = False
End If
End Sub