VB 开关灯问题
PrivateSubCommand1_Click()state=FalseIfstate=FalseThenShape1.FillColor=vbWhitestate=T...
Private Sub Command1_Click()
state = False
If state = False Then
Shape1.FillColor = vbWhite
state = True
Else
Shape1.FillColor = vblack
state = False
End If
End Sub
问题是 怎么让IF 重复运行,否则 电灯(fillcolor)只会由黑色变成白色,变不回黑色了。 展开
state = False
If state = False Then
Shape1.FillColor = vbWhite
state = True
Else
Shape1.FillColor = vblack
state = False
End If
End Sub
问题是 怎么让IF 重复运行,否则 电灯(fillcolor)只会由黑色变成白色,变不回黑色了。 展开
1个回答
展开全部
1,首先在 通用 部分申明一下state 这个变量为布尔型,以便全局调用。
2,应把if 中的state=false 拿出来。代码如下:
Dim state As Boolean
Private Sub Command1_Click()
If state = False Then
Shape1.FillColor = vbWhite
state = True
Else
Shape1.FillColor = vblack
state = False
End If
End Sub
Private Sub Form_Load()
state = False
End Sub
2,应把if 中的state=false 拿出来。代码如下:
Dim state As Boolean
Private Sub Command1_Click()
If state = False Then
Shape1.FillColor = vbWhite
state = True
Else
Shape1.FillColor = vblack
state = False
End If
End Sub
Private Sub Form_Load()
state = False
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询