您当前的位置: 首页 >  .net

Linux小百科

暂无认证

  • 0浏览

    0关注

    1185博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ASP.NET Razor – VB 逻辑条件简介

Linux小百科 发布时间:2022-01-23 10:26:53 ,浏览量:0

Razor 不是一种编程语言。它是服务器端的标记语言。编程逻辑:根据条件执行代码。

If 条件

VB 允许根据条件执行代码。

使用 if 语句来判断条件。根据判断结果,if 语句返回 true 或者 false:

  1. if 语句开始一个代码块
  2. 条件写在 if 和 then 之间
  3. 如果条件为真,if ... then 和 end if 之间的代码被执行

实例

@Code
Dim 
price=50
End Code


@If price>30 
Then    
@

The price is too high.

End If

Else 条件

if 语句可以包含 else 条件。

else 条件定义了当条件为假时被执行的代码。

实例

@Code
Dim 
price=20
End Code


@if price>30 then  
@

The price is too high.

Else @

The price is OK.

End If

注释:在上面的实例中,如果第一个条件为真,if 块的代码将会被执行。else 条件覆盖了除 if 条件之外的"其他所有情况"。

ElseIf 条件

多个条件判断可以使用 elseif 条件:

实例

@Code
Dim 
price=25
End Code


@If price>=30 Then  
@

The price is high.

ElseIf price>20 And price
关注
打赏
1665632672
查看更多评论
立即登录/注册

微信扫码登录

0.0409s