vb中利用timer控制标签左右循环移动

2025-02-23 17:32:25
推荐回答(5个)
回答1:

Dim
Step
As
Integer
Private
Sub
Form_Load()
Step
=
200
End
Sub
Private
Sub
Timer1_Timer()
If
lblshow.Left
>=
Me.ScaleWidth
Then
Step
=
-200
If
lblshow.Left
<=
0
Then
Step
=
200
lblshow.Left
=
lblshow.Left
+
Step
End
Sub

回答2:

直接每过一定长度的时间就把控件的坐标变一下就行了
比如说
Lable1.Left=Lable1.Left-100

回答3:

Dim FX As Integer '方向

Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
FX = 1
End Sub

Private Sub Timer1_Timer()
If Label1.Left < 0 Then FX = 1 '正方向
If Label1.Left > Me.Width Then FX = -1 '反方向
Label1.Left = Label1.Left + (200 * FX)
End Sub

回答4:

Dim Step As Integer

Private Sub Form_Load()
Step = 200
End Sub

Private Sub Timer1_Timer()

If lblshow.Left >= Me.ScaleWidth Then Step = -200
If lblshow.Left <= 0 Then Step = 200

lblshow.Left = lblshow.Left + Step

End Sub

回答5:

什么意思请写清楚些。