Was this helpful?
Dim Statement
 
Description
Use DIM to declare a variable outside any function and it is of MODULE scope.
Use DIM, to declare a variable within the function and it is of LOCAL scope.
Syntax
Dim variable [As datatype]
Remarks
The Dim statement uses the following parts:
variable - (required) Name of the variable.
As datatype - (optional) Specifies a datatype for the variable. Needed if it is anything other than Variant.
Put your Dim statements at the beginning of the procedure. You do NOT have to declare an object type if the variable is a variant, but you MUST declare object type if it is not a variant. Following are some declaration examples:
Dim qty
Dim qty As Integer
Dim myImport As DJImport
Limitation
There is no limitation of on the number of Private-level variables. In most statements, Dim declares a Private-scoped variable.
When used with a user-defined function, Dim create a function-scoped variable.
Example
This example uses the Dim statement to declare a variable in an expression, where "Result" is the variable name. The If Then Else statement is looking for Result A, else if Result A is not true, then a Null is returned:
Dim Result
Result = UCase(Left(FieldAt("/SOURCE/R1/Field1"), 1)
If Result == "A" Then
  Result = UCase(Left(FieldAt("/SOURCE/R1/Field1"), 1)
Else
  Result = ""
End If
Result
Last modified date: 02/09/2024