摘要:(200-06-14) VB.NET 教學 基本語法
IF 判斷式
Module TestIf
'主程式
Public Sub Main()
Dim i As Int32 = 60
If (i = 100) Then ' =,>=,<=,>,<,<>
System.Console.WriteLine(i.ToString() + " 等於100")'Code Black
Else
System.Console.WriteLine(i.ToString() + " 不等於100") 'Code Black
End If
End Sub
End Module
SELECT CASE
Module TestSelectCase
'多重分支流程
Public Sub Main()
Dim i As OpMode = OpMode.Query
Select Case i
Case OpMode.Add
System.Console.WriteLine("新增!!")
Case OpMode.Delete
Case OpMode.Modify
Case OpMode.Query
System.Console.WriteLine("查詢!!")
End Select
End Sub
End Module
Public Class AppUtil
End Class
Public Enum OpMode
Add
Modify
Delete
Query
End Enum
Module TestIfNested
Public Sub Main()
Dim i As Int32 = 59
If (i >= 60) Then
If (i >= 70) Then
If (i >= 80) Then
If (i >= 90) Then
System.Console.WriteLine("好成績!")
Else
System.Console.WriteLine("不錯!!")
End If
Else
System.Console.WriteLine("普通!!")
End If
Else
System.Console.WriteLine("及格邊緣!")
End If
Else
System.Console.WriteLine("不及格!!")
End If
End Sub
End Module
巢狀IF