if elseif then endif语句
PrivateSubCommandButton1_Click()x=TextBox1.ValueIfx<60ThenV1.Value=0V2.Value=0V3.Valu...
Private Sub CommandButton1_Click()
x = TextBox1.Value
If x < 60 Then
V1.Value = 0
V2.Value = 0
V3.Value = 0
V4.Value = 0
V5.Value = 1
ElseIf 60 <= x < 70 Then
V1.Value = 0
V2.Value = 0
V3.Value = 0
V4.Value = (x - 60) / 10
V5.Value = (70 - x) / 10
ElseIf 70 <= x < 80 Then
V1.Value = 0
V2.Value = 0
V3.Value = (x - 70) / 10
V4.Value = (80 - x) / 10
V5.Value = 0
ElseIf 80 <= x < 90 Then
V1.Value = 0
V2.Value = (x - 80) / 10
V3.Value = (90 - x) / 10
V4.Value = 0
V5.Value = 0
ElseIf 90 <= x <= 100 Then
V1.Value = (x - 90) / 10
V2.Value = (100 - x) / 10
V3.Value = 0
V4.Value = 0
V5.Value = 0
End If
End Sub
这是在Excel的vbp中编写的代码,为何运行不出,望懂得的人相助,多谢! 展开
x = TextBox1.Value
If x < 60 Then
V1.Value = 0
V2.Value = 0
V3.Value = 0
V4.Value = 0
V5.Value = 1
ElseIf 60 <= x < 70 Then
V1.Value = 0
V2.Value = 0
V3.Value = 0
V4.Value = (x - 60) / 10
V5.Value = (70 - x) / 10
ElseIf 70 <= x < 80 Then
V1.Value = 0
V2.Value = 0
V3.Value = (x - 70) / 10
V4.Value = (80 - x) / 10
V5.Value = 0
ElseIf 80 <= x < 90 Then
V1.Value = 0
V2.Value = (x - 80) / 10
V3.Value = (90 - x) / 10
V4.Value = 0
V5.Value = 0
ElseIf 90 <= x <= 100 Then
V1.Value = (x - 90) / 10
V2.Value = (100 - x) / 10
V3.Value = 0
V4.Value = 0
V5.Value = 0
End If
End Sub
这是在Excel的vbp中编写的代码,为何运行不出,望懂得的人相助,多谢! 展开
2个回答
2014-04-27
展开全部
ElseIf 60 <= x < 70 Then
应该是这样写的吧“elseif X>=60 and X<70 then ”吧
其实,直接用“elseif X<70 then” 就行了
应该是这样写的吧“elseif X>=60 and X<70 then ”吧
其实,直接用“elseif X<70 then” 就行了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询