关于vb.net的case的信息

VB中的CASE语句

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

成都创新互联公司专注于企业营销型网站、网站重做改版、开江网站定制设计、自适应品牌网站建设、H5高端网站建设商城网站开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为开江等各大城市提供网站开发制作服务。

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

在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.net select case语句为什么无效?

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

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的case的信息
网站网址:http://lszwz.com/article/dopgcse.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款