成都网站建设设计

将想法与焦点和您一起共享

case语句vb.net case语句必须以break结束

vb.net select case语句为什么无效?

用法不一样,。net中使用swithch

玛多网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联从2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联

vb中代码

Select Case itemc  

Case 1  

Response.Write("1")  

Case 2  

Response.Write("2")  

Case 3  

Response.Write("3")  

Case 4  

Response.Write("4")  

Case Else  

Response.Write("other")  

End Select

vb。net中代码

switch (itemc)  

{  

case 1:  

Response.Write("1");  

break;  

case 2:  

Response.Write("2");  

break;  

case 3:  

Response.Write("3");  

break;  

case 4:  

Response.Write("4");  

break;  

default:  

Response.Write("other");  

break;  

}

虽然都叫vb但是在用法上还是存在差异,语法问题

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

select case when a1 and b2 and c3 then d=1

when a1 and b2 and c3 then d=2

... end

至于写多少,没限制,,只要你语句不卡,,,

VB中的CASE语句

在VB.NET中VB.NET CASE语句就是比较常用的一种,下面是详细的介绍和代码的演示:

1、可以用 Select...Case 语句来替换 If...Then...Else 语句,所不同的是If 和 ElseIf 语句可在每个语句中计算不同的表达式,而 Select 语句对单个表达式只计算一次,然后将其和不同的值比较。

Function bonus(ByVal performance As Integer, _  ByVal salary As Decimal) As Decimal  

Select performance  

Case 1  

Return salary * 0.1  

Case 2  

Return salary * 0.3  

Case 3  

Return salary * 0.7  

Case 4  

Return salary * 0.9  

Case 5  

Return salary * 1.2  

End Select  

End Function

2、VB.NET Case语句可包含多个值和某个范围的值,代码案例如下:

Function bonus(ByVal performance As Integer, _  ByVal salary As Decimal) As Decimal  

Select performance  

Case 1  

Return salary * 0.1  

Case 2,3  

Return salary * 0.3  

Case 3 To 7  

Return salary * 0.7  

Case 8 To 9  

Return salary * 0.9  

Case Is = 15  

Return salary * 1.2  

Case Else  

Return 0  

End Select  

End Function


分享标题:case语句vb.net case语句必须以break结束
浏览地址:http://chengdu.cdxwcx.cn/article/hieghc.html