VB的一个IF循环语句语句问题

2025-02-16 07:40:43
推荐回答(4个)
回答1:

把If和Msgbox写在 统一行,是默认为没有EndIf的条件句,把换行Msgbox写入If和EndIf中间即可
ElseIf方式:
If CI = 1 Then
MsgBox "第五位数字是" & PcE
ElseIf CI = 2 Then
MsgBox "第三位数字是" & PcC
ElseIf CI = 3 Then
MsgBox "第二位数字是" & PcB
ElseIf CI = 4 Then
MsgBox "第一位数字是" & PcA
ElseIf CI >= 5 Then
MsgBox "这还提示啊......"
End If

回答2:

太难了

回答3:

Private Sub KEY_Click()
Static CI, CL As Integer
CI = 0
CI = CI + 1
If CI = 1 Then MsgBox "第五位数字是" & PcE
If CI = 2 Then MsgBox "第三位数字是" & PcC
If CI = 3 Then MsgBox "第二位数字是" & PcB
If CI = 4 Then MsgBox "第一位数字是" & PcA
If CI >= 5 Then MsgBox "这还提示啊......"
End If
End Sub

回答4:

如果IF 后面只跟一句代码 并且写在一行,就是你这种写法,是不需要End If的
只有
If x=y then
x=10
y=12
end if
才需要end if
你这种就应该使用
select case a
case 1 :
…………
case 2 :
…………
case 3 :
…………
end select
这种形式