1个回答
展开全部
问题在 Timer1_Timer()事件中,即使X为-100了,但触发事件后X又回到100了,Timer1_Timer()事件中X=100要去掉,改为如下:
Dim x As Integer
Option Explicit
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
x = 1
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 100 * x
If Label1.Left >= Form1.Width - Label1.Width Then x = -1
If Label1.Left <= 0 Then x = 1
End Sub
Dim x As Integer
Option Explicit
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
x = 1
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 100 * x
If Label1.Left >= Form1.Width - Label1.Width Then x = -1
If Label1.Left <= 0 Then x = 1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询