VB高手进来帮帮忙啊,谢谢

2024-12-16 23:02:54
推荐回答(2个)
回答1:

呵呵,肯定有问题啦,因为你“If (zjzz6 >= kjzz6) Then If (Abs(zzc6) > 6) Then sheng1 = 50 ”是“单行if语句结构”,已经是一个完整的结构了,所以相当于你后面的“elseif”的时候就没有了开始的那个“if”了^_^

使用if语句的时候要分清是使用“单行if语句”还是“块状if语句”,这样就不会出错了。嗯~你那段代码改成下面这样子的话应该就没有问题的了,如果有问题的话你再补充吧:
Dim sheng1, ping1, fu1 As Integer
If (zjzz6 >= kjzz6) Then
If (Abs(zzc6) > 6) Then
sheng1 = 50
ping1 = 30
fu1 = 20
ElseIf (Abs(zzc6) > 3) Then
sheng1 = 40
ping1 = 35
fu1 = 25
ElseIf (Abs(zzc6) >= 0) Then
sheng1 = 30
ping1 = 40
fu1 = 30
end if
ElseIf (zjzz6 < kjzz6) Then
If (Abs(zzc6) > 6) Then
sheng1 = 20
ping1 = 30
fu1 = 50
ElseIf (Abs(zzc6) > 3) Then
sheng1 = 25
ping1 = 35
fu1 = 40
Else
sheng1 = 25
ping1 = 40
fu1 = 35
End If
end if

回答2:

Dim sheng1, ping1, fu1 As Integer
If (zjzz6 >= kjzz6) Then If (Abs(zzc6) > 6) Then sheng1 = 50
ping1 = 30
fu1 = 20
ElseIf (Abs(zzc6) > 3) Then sheng1 = 40
ping1 = 35
fu1 = 25
ElseIf (Abs(zzc6) >= 0) Then sheng1 = 30
ping1 = 40
fu1 = 30
ElseIf (zjzz6 < kjzz6) Then If (Abs(zzc6) > 6) Then sheng1 = 20
ping1 = 30
fu1 = 50
ElseIf (Abs(zzc6) > 3) Then sheng1 = 25
ping1 = 35
fu1 = 40
Else: sheng1 = 25 '这个else是标签?
ping1 = 40
fu1 = 35
End If