编写一个滚动程序,单击开始按纽,窗体中部的标签开始自左向右移动,从右侧移出窗体后从新从左侧出现,周而复始;标签内容为:AA,移动速度由水平滚动条控制(最慢时每次移动1个单位,最快时每次移动100个单位);计时器的时间间隔为20毫秒;单击停止按纽,AA停止移动
參考答案:窗体内有command1,command2,label1,timer1,Hscroll1控件:
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Command1.Caption = "停止"
Command2.Caption = "开始"
Label1.Caption = "AA"
HScroll1.Min = 1
HScroll1.Max = 100
Timer1.Interval = 20
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Label1.Left > Me.Width Then
Label1.Left = -Label1.Width
End If
Label1.Left = Label1.Left + HScroll1.Value
End Sub