VB中滚动条的问题

2024-11-26 03:43:29
推荐回答(1个)
回答1:

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