vb程序设计编程题目:添加四个command控件,一个标签。运行程序后,当按command1时,标签不停的右移
当按command1时,标签不停的右移当按command2时,标签不停往左移当按command3时,运动停止当按command4时,退出程序...
当按command1时,标签不停的右移
当按command2时,标签不停往左移
当按command3时,运动停止
当按command4时,退出程序 展开
当按command2时,标签不停往左移
当按command3时,运动停止
当按command4时,退出程序 展开
展开全部
Dim k As Integer
Private Sub Command1_Click()
Timer1.Interval = 50
k = 100
End Sub
Private Sub Command2_Click()
Timer1.Interval = 50
k = -100
End Sub
Private Sub Command3_Click()
Timer1.Interval = 0
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Label1.AutoSize = True
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + k
If Label1.Left <= 0 Then
Label1.Left = 0
Timer1.Interval = 0
End If
If Label1.Left + Label1.Width >= Me.ScaleWidth Then
Label1.Left = Me.ScaleWidth - Label1.Width
Timer1.Interval = 0
End If
End Sub
Private Sub Command1_Click()
Timer1.Interval = 50
k = 100
End Sub
Private Sub Command2_Click()
Timer1.Interval = 50
k = -100
End Sub
Private Sub Command3_Click()
Timer1.Interval = 0
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Label1.AutoSize = True
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + k
If Label1.Left <= 0 Then
Label1.Left = 0
Timer1.Interval = 0
End If
If Label1.Left + Label1.Width >= Me.ScaleWidth Then
Label1.Left = Me.ScaleWidth - Label1.Width
Timer1.Interval = 0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub form_load()
timer1.enabled=false
timer1.interval=50
timer2.enabled=false
timer2.interval=50
end sub
private sub command1_click()
timer1.enabled=true
timer2.enabled=false
end sub
private sub command2_click()
timer2.enabled=true
timer1.enabled=false
end sub
private sub command3_click()
timer1.enabled=false
timer2.enabled=false
end sub
private sub command4_click()
end
end sub
private sub timer1_timer()
label1.left=label1.left+50
end sub
private sub timer2_timer()
label1.left=label1.left-50
end sub
timer1.enabled=false
timer1.interval=50
timer2.enabled=false
timer2.interval=50
end sub
private sub command1_click()
timer1.enabled=true
timer2.enabled=false
end sub
private sub command2_click()
timer2.enabled=true
timer1.enabled=false
end sub
private sub command3_click()
timer1.enabled=false
timer2.enabled=false
end sub
private sub command4_click()
end
end sub
private sub timer1_timer()
label1.left=label1.left+50
end sub
private sub timer2_timer()
label1.left=label1.left-50
end sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按一下动一下,还是按了之后连续运动?另外到边界的时候是否需要继续运动,还是停止,还是反方向运动?
追问
是按了之后连续运动,到外边继续运动
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询