如何创建动态案例功能?

时间:2014-03-17 08:53:38

标签: asp-classic

我在我的asp代码中使用它,我想压缩这段代码。

专家asp请帮我修改我的代码,我还需要动态案例

for i=1 to 50
    ....
next


<%m=40000
Dim StockValue:StockValue=m
numn=30000

 Select Case True
Case StockValue<=numn*1:G=1:Case StockValue<=numn*2:G=2:
Case StockValue<=numn*3:G=3:Case StockValue<=numn*4:G=4:
Case StockValue<=numn*5:G=5:Case StockValue<=numn*6:G=6:
Case StockValue<=numn*7:G=7:Case StockValue<=numn*8:G=8:
Case StockValue<=numn*9:G=9:Case StockValue<=numn*10:G=10:
Case StockValue<=numn*11:G=11:Case StockValue<=numn*12:G=12:
Case StockValue<=numn*13:G=13:Case StockValue<=numn*14:G=14:
Case StockValue<=numn*15:G=15:Case StockValue<=numn*16:G=16:
Case StockValue<=numn*17:G=17:Case StockValue<=numn*18:G=18:
Case StockValue<=numn*19:G=19:Case StockValue<=numn*20:G=20:
Case StockValue<=numn*21:G=21:Case StockValue<=numn*22:G=22:
Case StockValue<=numn*23:G=23:Case StockValue<=numn*24:G=24:
Case StockValue<=numn*25:G=25:Case StockValue<=numn*26:G=26:
Case StockValue<=numn*27:G=27:Case StockValue<=numn*28:G=28:
Case StockValue<=numn*29:G=29:Case StockValue<=numn*30:G=30:
Case StockValue<=numn*31:G=31:Case StockValue<=numn*32:G=32:
Case StockValue<=numn*33:G=33:Case StockValue<=numn*34:G=34:
Case StockValue<=numn*35:G=35:Case StockValue<=numn*36:G=36:
Case StockValue<=numn*37:G=37:Case StockValue<=numn*38:G=38:
Case StockValue<=numn*39:G=39:Case StockValue<=numn*40:G=40:
Case StockValue<=numn*41:G=41:Case StockValue<=numn*42:G=42:
Case StockValue<=numn*43:G=43:Case StockValue<=numn*44:G=44:
Case StockValue<=numn*45:G=45:Case StockValue<=numn*46:G=46:
Case StockValue<=numn*47:G=47:Case StockValue<=numn*48:G=48:
Case StockValue<=numn*49:G=49:Case StockValue<=numn*50:G=50:

Case Else
End Select
Response.write(g)%>

现在,我还需要动态案例功能。)

1 个答案:

答案 0 :(得分:0)

您可以使用Execute()

Dim cmd, min, max, StockValue, numn, G

m = 40000
numn = 30000   

StockValue = m
min = 1
max = 50

cmd = cmd & "Select Case True" & vbCrLf
For i = min To max
  cmd = cmd & "Case StockValue <= numn * " & i & ": G = " & i & vbCrLf
Next
cmd = cmd & "Case Else" & vbCrLf
cmd = cmd & "End Select"

Call Execute(cmd)