VB中滚动条的问题

来源:百度知道 编辑:UC知道 时间:2024/05/18 22:46:11
建一个工程,运行时一个标签显示当前时间,并在窗体中来回移动,当它碰到窗体边框时反向弹回.一个水平滚动条控制它的移动速度.

请问该咋编~?~

Dim i%

Private Sub Form_Load()
Label1.AutoSize = True
Label1.Caption = Time
Timer1.Enabled = True
Timer1.Interval = 120
HScroll1.Max = 100
i = 0
End Sub

Private Sub HScroll1_Change()
Timer1.Interval = 120 - HScroll1.Value
End Sub

Private Sub Timer1_Timer()
If i = 0 Then
Label1.Left = Label1.Left - 30
If Label1.Left <= 0 Then i = 1
ElseIf i = 1 Then
Label1.Left = Label1.Left + 30
If Label1.Left >= Me.ScaleWidth - Label1.Width Then i = 0
End If
End Sub