Dim x As Double

x = 20.1

Dim y As Integer

implicit narrowing conversion

y = x doesnt compile under Option Strict

Dim x As Double

x = 20.1

Dim y As Integer

explicit narrowing conversion

y = CInt(x) compiles under Option Strict

If Function1() And Function2() Then

statement block

End If

Dim x As Integer

set x to 0 for false or anything else for true

If x Then

execute statement block

End If

Dim x As Integer

Dim y As Integer

Dim z As Integer

x = 3

Y = 6

z = x And y doesnt compile

Visual Basic.NET提供了四种新的按位比较运算符：BitNot,BitAnd, BitOr, 和BitXor。这些运算符允许你在类型安全的方式下实行按位比较运算。比如，你可以用这些运算符中的一个对两个integer值的每一位来实现OR运算，还可以实现位掩码。下面是使用BitOr和BitAnd的一个例子：

Dim x As Integer = 3

Dim y As Integer = 6

Dim z As Integer

OR bits together

z = x BitOr y z now equals 7

AND to find intersection of bits

z = x BitAnd y z now equal 2

declare an array with 3 elements from 0 to 2

Dim array1(3) As Integer

array1(0) = 2

array1(1) = 4

array1(2) = 8

index out of range exception

array1(3) = 16

Visual Basic.NET为初始化数组提供了一种新的语法。你可以只用一行代码完成数组的声明和初始化。就像这样：

new array initialization syntax

Dim array1 As Integer() = {2, 4, 8}

Visual Basic的早期版本中，你可以用For Each循环遍历一个数组。

Dim x As Integer

For Each x In array1

Console.WriteLine(x)

Next

Dim i As Integer

For i = 0 To (array1.Length - 1)

Console.WriteLine(array1(i))