在VB.net中,使用Select Case语句,Case后能接几个判断语句吗?

举个简单例子:当a>1 and b>2 and c>3时,d=1
当a>1 and b>2 and c<3时,d=2
......
请问用Select Case语句怎么写?不想用If语句,因为这种情况在VB中用If 语句浪费时间。

第1个回答  2015-08-26
select case when a>1 and b>2 and c>3 then d=1
when a>1 and b>2 and c<3 then d=2
... end
至于写多少,没限制,,只要你语句不卡,,,追问

Select Case的结构不对吧?
应该是:
Select Case e
Case e1
语句1
Case e2
语句2
......
请问按照这种结构怎么填充上面的例子啊?其中e,e1分别是什么?

追答

2种写法
1 select case a when 1 then d=2
2 select case when a=1 then d=2
你这种多条件的用第2种清晰点吧,,,

追问

亲,我要用在VB中,你的回答还是没有按照格式写,我不明白。

本回答被网友采纳
相似回答