vb 牛人在哪里?

来源:百度知道 编辑:UC知道 时间:2024/06/06 20:11:01
我想编个程序,是这样的:三个命令按钮紧密排成一排,在窗体上移动,当在最左边时,向右移动,当移动到最右边时,向左移动,如此循环,我编的运行不出来呀,求vb高手帮我一把,不胜感激!
谢谢!
我的代码:
Private Sub Form_Load()
Timer1.Enabled = True
Timer2.Enabled = False

End Sub

Private Sub Timer1_Timer()’c1,c2,c3为按钮的name属性
C1.Left = C1.Left + 50
C2.Left = C2.Left + 50
C3.Left = C3.Left + 50
If C3.Left >= Form1.Width - C3.Width Then
Timer2.Enabled = True
Timer1.Enabled = False
End If

End Sub

Private Sub Timer2_Timer()
C1.Left = C1.Left - 50
C2.Left = C2.Left - 50
C3.Left = C3.Left - 50
If C1.Left <= 0 Then
Timer1.Enabled = True
timer2.Enabled = false
End If

End Sub
运行问题:走到窗体右边时,不会动了!
这个问题我问了一次,可能分加错了,这次保证有分,回答的好,有追加的!

timer2.Interval = 1000

你的程序里面timer2.Interval = 0 是吧???将其改为不为零的值

我给你的代码是经过测试的,没问题的。你把三个按钮上下并排试试。

代码没有任何问题
可能是你的两个时钟控件的Interval属性有为0的值

没有任何问题!!