Bookshelf Home | Contents | Index | PDF |
Siebel VB Language Reference > VB Language Reference > Global StatementThis standard VB statement declares Global variables for use in a Basic program. SyntaxGlobal variableName [As type] [,variableName [As type]] ... ReturnsUsageIn 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. ArraysThe 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:
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. NumbersNumeric 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. RecordsRecord 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. StringsSiebel 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:
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: VariantsDeclare 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. ExampleThis example contains two subroutines that share the variables total and acctno, and the record grecord. (general)(declarations) Global acctno as Integer Sub CreateFile Sub Button_Click See AlsoConst Statement |
Siebel VB Language Reference |