[ASP]select case範圍選擇方式

有關網頁及相關語法的討論
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[ASP]select case範圍選擇方式

文章 tim »

在 asp 中使用 Select Case 判定範圍方式, 利用 Select Case True, 並配合判斷式來操作即可, 範例如下:

代碼: 選擇全部

id = Request("id")

Select Case True
 Case id < 100  ' id < 100
   str = "id < 100"
 Case fid < 200 ' id >=100 and < 200
   str = "id < 200"
 Case fid < 300 ' id >=200 and < 300
   str = "id < 300"
 Case fid < 400 ' id >=300 and < 400
   str = "id < 400"
 Case Else
   str = "id unknown"
End Select

Response.Write str
多多留言, 整理文章, 把經驗累積下來.....
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

Re: [ASP]select case範圍選擇方式

文章 tim »

另外的延伸應用, 多重條件, 如下:

代碼: 選擇全部

strType = Request("type")

Select Case True
  Case strType = "A" or strType = "B"
    type = 1
  Case strType = "C" or strType = "D" or strType = "E"
    type = 2
  Case Else
    type = 0
End Select

Response.Write "type=" & type
可以合併多重條件於一行的方式來將程式碼簡化
多多留言, 整理文章, 把經驗累積下來.....
回覆文章