×

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 Sub过程(子程序)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 Nested If 嵌套If语句


VB.Net  决策VB.Net 决策


在VB.Net中总是合法的嵌套If-Then-Else语句,这意味着您可以在另一个If ElseIf语句中使用一个If或ElseIf语句。

语法:

If( boolean_expression 1)Then
   'Executes when the boolean expression 1 is true 
   If(boolean_expression 2)Then
         'Executes when the boolean expression 2 is true 
   End If
End If
您可以嵌套ElseIf ... Else的方式,与嵌套If语句类似。

示例:

Module decisions
   Sub Main()
      'local variable definition
      Dim a As Integer = 100
      Dim b As Integer = 200
      ' check the boolean condition 
      If (a = 100) Then
          ' if condition is true then check the following 
          If (b = 200) Then
              ' if condition is true then print the following 
              Console.WriteLine("Value of a is 100 and b is 200")
          End If
      End If
      Console.WriteLine("Exact value of a is : {0}", a)
      Console.WriteLine("Exact value of b is : {0}", b)
      Console.ReadLine()
   End Sub
End Module

当上述代码被编译和执行时,它产生以下结果:
Value of a is 100 and b is 200
Exact value of a is : 100
Exact value of b is : 200


VB.Net  决策VB.Net 决策


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)