# Visual Basic 中的變數宣告Variable Declaration in Visual Basic

## 宣告資料類型Declaring Data Type

• 基本資料類型，例如 BooleanLongDecimalAn elementary data type, such as Boolean, Long, or Decimal

• 複合資料型別，例如陣列或結構A composite data type, such as an array or structure

• 在您的應用程式或另一個應用程式中定義的物件類型或類別An object type, or class, defined either in your application or in another application

• .NET Framework 類別，例如 LabelTextBoxA .NET Framework class, such as Label or TextBox

• 介面類別型，例如 IComparableIDisposableAn interface type, such as IComparable or IDisposable

Dim i, j, k As Integer
' All three variables in the preceding statement are declared as Integer.
Dim l, m As Long, x, y As Single
' In the preceding statement, l and m are Long, x and y are Single.


## 區域類型推斷Local Type Inference

Public Sub inferenceExample()

' Using explicit typing.
Dim num1 As Integer = 3

' Using local type inference.
Dim num2 = 3

End Sub