Siebel VB Language Reference > VB Language Reference >
This standard VB statement declares Global variables for use in a Basic program.
Global variableName [As type] [,variableName [As type]] ...
A variable name
The variable's data type
In Siebel VB, a Global variable must generally be declared in every module from which you wish to access that variable. Declare Global variables in the (general) (declarations) section for the module.
Basic is a strongly typed language: variables must be given a data type or they are assigned a type of variant.
If the As clause is not used, the type of the global variable can be specified by using a type character as a suffix to variableName. The two different type-specification methods can be intermixed in a single Global statement (although not on the same variable).
Regardless of which mechanism you use to declare a global variable, you can choose to use or omit the type character when referring to the variable in the rest of your program. The type suffix is not considered part of the variable name.
The available data types are:
The available data types for arrays are numbers, strings, variants, and records. Arrays of arrays, dialog box records, and objects are not supported.
Array variables are declared by including a subscript list as part of the variableName. The syntax to use for variableName is:
, ... ]) [As typeName
where subscriptRange is of the format:
If startSubscript is not specified, 0 is used as the default. The Option Base statement can be used to change the default to 1.
Both the startSubscript and the endSubscript are valid subscripts for the array. The maximum number of subscripts that can be specified in an array definition is 60.
If no subscriptRange is specified for an array, the array is declared as a dynamic array. In this case, the ReDim statement must be used to specify the dimensions of the array before the array can be used.
Numeric variables can be declared using the As clause and one of the following numeric types: currency, integer, long, single, and double. Numeric variables can also be declared by including a type character as a suffix to the name.
Record variables are declared by using an As clause and a type that has previously been defined using the Type statement. The syntax to use is:
Records are made up of a collection of data elements called fields. These fields can be of any numeric, string, variant, or previously defined record type. For details on accessing fields within a record, read Type Statement.
You cannot use the Global statement to declare a dialog record.
Siebel VB supports two types of strings, fixed-length and dynamic. Fixed-length strings are declared with a specific length (between 1 and 32767) and cannot be changed later. Use the following syntax to declare a fixed-length string:
As String * length
Dynamic strings have no declared length, and can vary in length from 0 to 32767. The initial length for a dynamic string is 0. Use the following syntax to declare a dynamic string:
Declare variables as variants when the type of the variable is not known at the start of, or might change during, the procedure. For example, a variant is useful for holding input from a user when valid input can be either text or numbers. Use the following syntax to declare a variant:
Variant variables are initialized to vartype Empty.
This example contains two subroutines that share the variables total and acctno, and the record grecord.
acctno As Integer
Global acctno as Integer
Global total as Integer
Global grecord as acctrecord
Declare Sub CreateFile
x = 1
grecord.acctno = 2345
Open "c:\temp001" For Output as #1
Do While grecord.acctno <> 0
grecord.acctno = 0
If grecord.acctno <> 0 then
Print #1, grecord.acctno
x = x + 1
total = x-1
Dim newline as String
newline = Chr$(10)
Open "c:\temp001" For Input as #1
msgtext = "The new account numbers are: " & newline
For x = 1 to total
Input #1, grecord.acctno
msgtext = msgtext & newline & grecord.acctno
Option Base Statement