Back to index

Dim statement
Used to declare and allocate storage space for variables and arrays.

Format:

  Dim name[ (boundlist) ] [ As type ] 

Syntax:

Remarks:

Variables declared with Dim are available to all code within the region containing the Dim statement. If they are declared in a module but outside any procedure or function, they can be accessed from anywhere within that module.

Variables declared inside a procedure or a function are accessible only from within that procedure or function.

See also:

- Assign statement: Assigns variable, constant, or expression to variable or array item
- Using arrays

Example:

  ' Declare variable s. It can change its type freely
  Dim s
  
  Dim Number As Integer
  Dim MyInt1, MyInt2 As Integer
  Dim MyInt As Integer, MyFloat As Floating

  ' Array declarations
  Dim MyArray(50) ' Array of 50 elements

  ' Matrix is a two-dimensional array of type Integer.
  Dim Matrix(3, 4) As Integer 

  ' Matrix3 is a three-dimensional array of type Floating.
  Dim Matrix3(5, 9, 5) As Floating


Copyright (c) 2000-2005 by SymbianWare OHG. All rights reserved.
SymbianWare and SymbianWare logo are trademarks of SymbianWare OHG.