lang • localdecl

Local Variable Declaration

DIM Identifier AS Datatype [ = Expression ]

Declare a local variable in a procedure or function.

This variable is only accessible to the procedure or function where it is declared.

Examples

Dim iVal As Integer
Dim sName As String
Dim hObject As Object
Dim hCollection As Collection

Initialization

The variable can be initialized with any expression.

Examples

Dim bCancel As Boolean = True
Dim Languages As String[] = ["fr", "it", "es", "de", "ja"]
Dim DefaultLanguage As String = Languages[1]

Alternatively, you can initialize the variable with a newly instanciated object.

DIM Identifier AS NEW Class ( Arguments ... )

Examples

Dim aTask As New String[]
Dim aCollection As New Collection(gb.Text)

Or you can initialize the variable with a native dynamic array. See Array Declaration for more information.

Multiple Declarations

You can declare several variables on the same line:

Examples

Dim Text As String, Matrix As New Float[3, 3]
Dim X, Y, W, H As Integer

See also