用timer,command,label,text控件编写程序,设计一个倒计时程序,从60到1,再从1到60,用vb 编程
5个回答
展开全部
Text1.Text = 6
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000
Timer2.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = x
x = x - 1
If x = 0 Then Timer2.Enabled = True: Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
Label1.Caption = x
x = x + 1
If x = 6 Then Timer1.Enabled = True: Timer2.Enabled = False
End Sub
一开始那个等于六其实没什么必要,明天考试全靠你了志勇O(∩_∩)O哈哈~呦西
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000
Timer2.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = x
x = x - 1
If x = 0 Then Timer2.Enabled = True: Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
Label1.Caption = x
x = x + 1
If x = 6 Then Timer1.Enabled = True: Timer2.Enabled = False
End Sub
一开始那个等于六其实没什么必要,明天考试全靠你了志勇O(∩_∩)O哈哈~呦西
展开全部
Dim i As Integer
Private Sub Form_Load()
i = 60
Text1.Text = 60
End Sub
Private Sub Timer1_Timer()
If i < 1 Then i = 60
i = i - 1
Label1.Caption = "倒计时:" & i
End Sub
Private Sub Form_Load()
i = 60
Text1.Text = 60
End Sub
Private Sub Timer1_Timer()
If i < 1 Then i = 60
i = i - 1
Label1.Caption = "倒计时:" & i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim x As Integer
Private Sub Command1_Click()
x = Val(Text1.Text)
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Text1.Text = 60
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000
Timer2.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = x
x = x - 1
If x = 0 Then Timer2.Enabled = True: Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
Label1.Caption = x
x = x + 1
If x = 60 Then Timer1.Enabled = True: Timer2.Enabled = False
End Sub
Private Sub Command1_Click()
x = Val(Text1.Text)
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Text1.Text = 60
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000
Timer2.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = x
x = x - 1
If x = 0 Then Timer2.Enabled = True: Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
Label1.Caption = x
x = x + 1
If x = 60 Then Timer1.Enabled = True: Timer2.Enabled = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim JJ As String'判断是加还是减
Private Sub Command1_Click()
Timer1.Interval = 1000’设定时间1秒
If UCase(Text1.Text) = "TEXT" Then Text1.Text = 60‘初始TEXT1为60
If UCase(Label1.Caption) = "LABEL1" Then Label1.Caption = "1"’初始LABEL1为1
JJ = "+"'初始步长为加
Timer1.Enabled = Not Timer1.Enabled‘启动或停止
End Sub
Private Sub Timer1_Timer()
If Int(Label1.Caption) <= 1 Then’判断下限
JJ = "+"
ElseIf Int(Label1.Caption) >= Int(Text1.text) Then‘判断上限
JJ = "-"
End If
If JJ = "+" Then
Label1.Caption = Int(Label1.Caption) + 1’操作加
ElseIf JJ = "-" Then
Label1.Caption = Int(Label1.Caption) - 1‘操作减
End If
End Sub
以上为代码,拖出timer Command Label text 控件放到窗口中,复制代码进去就能工作,
Private Sub Command1_Click()
Timer1.Interval = 1000’设定时间1秒
If UCase(Text1.Text) = "TEXT" Then Text1.Text = 60‘初始TEXT1为60
If UCase(Label1.Caption) = "LABEL1" Then Label1.Caption = "1"’初始LABEL1为1
JJ = "+"'初始步长为加
Timer1.Enabled = Not Timer1.Enabled‘启动或停止
End Sub
Private Sub Timer1_Timer()
If Int(Label1.Caption) <= 1 Then’判断下限
JJ = "+"
ElseIf Int(Label1.Caption) >= Int(Text1.text) Then‘判断上限
JJ = "-"
End If
If JJ = "+" Then
Label1.Caption = Int(Label1.Caption) + 1’操作加
ElseIf JJ = "-" Then
Label1.Caption = Int(Label1.Caption) - 1‘操作减
End If
End Sub
以上为代码,拖出timer Command Label text 控件放到窗口中,复制代码进去就能工作,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim F As Boolean, L As Integer
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Label1.Caption = Text1.Text
Command1.Caption = "退出"
F = True
Timer1.Enabled = True
Else
End
End If
End Sub
Private Sub Form_Load()
Text1.Text = 60
Label1.Caption = ""
Timer1.Interval = 1000
Timer1.Enabled = False
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
If F Then
Label1.Caption = Label1.Caption - 1
Else
Label1.Caption = Label1.Caption + 1
End If
L = Label1.Caption
If L = 0 Or L = Val(Text1.Text) Then F = Not F
End Sub
已经运行过.
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Label1.Caption = Text1.Text
Command1.Caption = "退出"
F = True
Timer1.Enabled = True
Else
End
End If
End Sub
Private Sub Form_Load()
Text1.Text = 60
Label1.Caption = ""
Timer1.Interval = 1000
Timer1.Enabled = False
Command1.Caption = "开始"
End Sub
Private Sub Timer1_Timer()
If F Then
Label1.Caption = Label1.Caption - 1
Else
Label1.Caption = Label1.Caption + 1
End If
L = Label1.Caption
If L = 0 Or L = Val(Text1.Text) Then F = Not F
End Sub
已经运行过.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询