你的位置:| 首页网站建设asp中select case 语法与实例→文章正文  
文章导航


asp中select case 语法与实例

何时使用 Select Case, 个人认为当判断条件大于三的时候, 应当采用 Select Case, 总比一大堆 if...else 看起来清晰.

1. 判断数字
2. 判断真假
3. 判断字符串

实例:

1. 判断数字
<%'添加更新数据用
'sample call '''// call schkaddorupopt(htmloff_,ubboff_,title_,content_) \\'''
sub schkaddorupopt(html,ubb,title,content)
f=html&ubb
select case f
case 00 'html 和 ubb 都没选择
title=textToHtml(trim(title))
content=textToHtml(content)
case 11 'html 和 ubb 都选择
title=textToHtml1(trim(title))
content=textToHtml1(content_)
case 01 'HTML 没选择, UBB 选择
title_=textToHtmlNullUBB(trim(title))
content_=textToHtmlNullUBB(content_)
case 10 'HTML 选择, UBB 没选择
title=textToHtml(trim(title))
content=textToHtml(content)
end select
end sub
%>

2. 判断真假
<%'读取数据用
'sample call '''// call schkreadopt(htmloff_,ubboff_,tt_,ct_) \\'''
sub schkreadopt(html,ubb,title,content)
f=html&ubb
select case f
case true&true 'UBB HTML 都选择
title=title
content=htmlToTextHTMLonUBBoff(content)
case false&false 'UBB HTML 都没选择
title=htmlToText(title)
content=htmlToText(content)
case false&true 'UBB选择, HTML 没选择
title=htmlToText(title)
content=htmlToText(content)
case true&false 'UBB 没选择, HTML 选择
title=htmlToTextNullUBB(title)
content=htmlToTextNullUBB(content)
end select
end sub
%>

3. 判断字符串
<%'判断查询用
id_=request("id")
select case id_
case "tag"
sql= "select * from v_page_tag_at_of_tg where b.tag like '%"&request("tag")&"%' order by a.articleid desc"
case "bytagid"
sql= "select * from v_page_tag_tg_only order by tagid desc"
case "byarticleid"
sql= "SELECT * FROM v_page_tag_at_and_tg order by articleid desc"
case "bytagdate"
sql= "select * from v_page_tag_tg_only order by tagdate desc"
case "byarticledate"
sql= "SELECT * FROM v_page_tag_at_and_tg order by dateandtime desc"
case "bytaghits"
sql= "select * from v_page_tag_tg_only order by tagview desc"
case "byarticlehits"
sql= "SELECT * FROM v_page_tag_at_and_tg order by hits desc"
case else
sql= "select distinct tag from cttag order by tag asc"
end select
%>


  上一页 1 2 3 4 5 下一页
 
公司简介 在线客服 客服中心 意见反馈 相关法律 隐私条款 广告服务 友情链接
Q链:515347638  电子邮箱:hanen@126.com 粤ICP备05086553