- VB.Net 基础教程
- VB.Net - 首页
- VB.Net - 概述
- VB.Net - 环境设置
- VB.Net - 程序结构
- VB.Net - 基本语法
- VB.Net - 数据类型
- VB.Net - 变量
- VB.Net - 常量
- VB.Net - 修饰符
- VB.Net - 语句
- VB.Net - 指令
- VB.Net - 运算符
- VB.Net - 决策
- VB.Net - 循环
- VB.Net - 字符串
- VB.Net - 日期和时间
- VB.Net - 数组
- VB.Net - 集合
- VB.Net - 函数
- VB.Net - 子程序
- VB.Net - 类和对象
- VB.Net - 异常处理
- VB.Net - 文件处理
- VB.Net - 基本控件
- VB.Net - 对话框
- VB.Net - 高级窗体
- VB.Net - 事件处理
- VB.Net 高级教程
- VB.Net - 正则表达式
- VB.Net - 数据库访问
- VB.Net - Excel 表格
- VB.Net - 发送电子邮件
- VB.Net - XML 处理
- VB.Net - Web编程
- VB.Net 有用资源
- VB.Net - 快速指南
- VB.Net - 有用资源
- VB.Net - 讨论
VB.Net - If...Then 语句
这是最简单的控制语句形式,经常用于决策和更改程序执行的控制流。if-then 语句的语法如下:
If condition Then [Statement(s)] End If
其中,condition 是布尔或关系条件,Statement(s) 是简单语句或复合语句。If-Then 语句的示例如下:
If (a <= 20) Then c= c+1 End If
如果条件计算结果为真,则将执行 If 语句内的代码块。如果条件计算结果为假,则将执行 If 语句结束后的第一组代码(在结束 End If 之后)。
流程图
示例
Module decisions
Sub Main()
'local variable definition
Dim a As Integer = 10
' check the boolean condition using if statement
If (a < 20) Then
' if condition is true then print the following
Console.WriteLine("a is less than 20")
End If
Console.WriteLine("value of a is : {0}", a)
Console.ReadLine()
End Sub
End Module
编译并执行上述代码后,将产生以下结果:
a is less than 20 value of a is : 10
vb.net_decision_making.htm
广告