gpt4 book ai didi

vbscript - 选择有条件的案例(经典 ASP)

转载 作者:行者123 更新时间:2023-12-03 06:42:17 27 4
gpt4 key购买 nike

<%
i=2
Select Case i
Case 1,2,3,4,5,7,8,9,10
response.write("Grade A")
Case 11,12,13,14,15,16,17,18,19,20
response.write("Grade B")
Case 21,22,23,24,25,26,27,28,29,30
response.write("Grade C")
Case 31,32,33,34,35,36,37,38,39,40
response.write("Grade D")
Case Else
response.write("Invalid")
End Select
%>

如何用更小的语句替换 1,2,3..。我尝试将 1 放入 10,但显示错误。

感谢任何帮助,谢谢!

最佳答案

一些替代方案

grade = "Invalid"
Select Case True
Case i < 1
Case i < 11 : grade = "Grade A"
Case i < 21 : grade = "Grade B"
Case i < 31 : grade = "Grade C"
Case i < 41 : grade = "Grade D"
End Select

If i > 0 And i < 41 Then 
grade = "Grade " + Chr(Asc("A") + (i-1)\10)
Else
grade = "Invalid"
End If

If i > 0 And i < 41 Then 
grade = Array("Grade A", "Grade B", "Grade C", "Grade D")((i-1)\10)
Else
grade = "Invalid"
End If

编辑以纠正 Ekkehard.Horner 指出的错误

关于vbscript - 选择有条件的案例(经典 ASP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43214055/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com