'ZT是当前状态记录,Qzt是前状态记录,SJ是时间记录
Dim ZT As Integer, Qzt As Integer, Sj As Integer
Private Sub Command1_Click()
If Command1Caption = "开始" Then
Command1Caption = "20停止"
Timer1Enabled = True
Shape3FillColor = &HFF&
ZT = 3
Qzt = 3
Else
Command1Caption = "开始"
Timer1Enabled = False
Shape1FillColor = &H4000&
Shape2FillColor = &H8080&
Shape3FillColor = &H40&
ZT = 0
End If
End Sub
Private Sub Form_Load()
Shape1FillStyle = 0 '绿灯
Shape2FillStyle = 0 '黄灯
Shape3FillStyle = 0 '红灯
Shape1FillColor = &H4000& '暗绿
Shape2FillColor = &H8080& '暗黄
Shape3FillColor = &H40& '暗红
Shape1Shape = 3 '圆形
Shape2Shape = 3
Shape3Shape = 3
Command1Caption = "开始"
Timer1Interval = 1000 '一秒一次加入倒计时
Timer1Enabled = False
End Sub
Private Sub Timer1_Timer()
Sj = Sj + 1
If ZT = 1 Or ZT = 3 Then Command1Caption = (20 - Sj) & "停止"
If ZT = 2 Then Command1Caption = (5 - Sj) & "停止"
If Sj = 20 And (ZT = 1 Or ZT = 3) Then
Shape1FillColor = &H4000&
Shape2FillColor = &H8080&
Shape3FillColor = &H40&
Select Case ZT
Case 1
Shape2FillColor = &HFFFF&
ZT = 2
Qzt = 1
Case 3
Shape2FillColor = &HFFFF&
ZT = 2
Qzt = 3
End Select
Sj = 0
End If
If Sj = 5 And ZT = 2 Then
Shape1FillColor = &H4000&
Shape2FillColor = &H8080&
Shape3FillColor = &H40&
If Qzt = 3 Then
Shape1FillColor = &HFF00&
ZT = 1
Else
Shape3FillColor = &HFF&
ZT = 3
End If
Sj = 0
End If
End Sub
Dim a As Double
Dim b As Double
Private Sub Command1_Click()
a = Text1Text
b = 2 Sqr(((05 a) ^ 2) 2 / 3)
Text2Text = b
End Sub
Private Sub Form_Load()
Text1Text = ""
Text2Text = ""
End Sub
貌似这么着就可以,其实就是一个公式。。。俩框是textbox,一个command按钮,名字都是默认的,完全不值100分~
Private Sub Worksheet_Change(ByVal Target As Range)
If TargetColumn = 1 Then TargetOffset(0, 6) = "vb简单代码"
End Sub
以上就是关于vb写一个简单红绿灯程序代码,希望能注释和思路写清楚一点,我菜鸟!谢谢全部的内容,包括:vb写一个简单红绿灯程序代码,希望能注释和思路写清楚一点,我菜鸟!谢谢、求一个简单VB代码程序、vb简单代码等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)