| Bookshelf Home | Contents | Index | PDF | ![]() |
|
Siebel VB Language Reference > Using Siebel VB > About Declaring Procedures and Variables > Declaring VariablesThis topic includes information about using the Declare Variable statement to declare a variable. For more information about this statement and the format and arguments you can use with it, see Declare Variable Statement. It is recommended that you place procedure-level Declare Variable statements at the beginning of the procedure. For information about explicitly declaring a variable, see Force Explicit Declaration Statement. Determining Variable ScopeYou can share a variable across modules. The following locations where you declare a variable determines the scope of the variable:
If you declare a variable that has the same name as a module variable, then you cannot access the module variable. For more information, see Declare Global Variable Statement. Specifying the Type When You Declare a VariableWhen you declare a variable, you can specify one of the following types: If you do not specify a data type, then Siebel VB assigns the variant data type to this variable. If you do not include the As clause, then you can specify the type argument. To specify this argument, you use a type character as a suffix of the variableName argument. You can use both type specification techniques in a single Declare Variable statement. You cannot use them simultaneously on the same variable. You can omit the type character when you reference the variable in your code. The type suffix is not part of the variable name. For more information, see About Data Types. Declaring an Array VariableThe following data types are available for an array: You cannot use the Declare Variable statement to declare an array of arrays or an array of objects. To declare an array variable, you include a subscript list as part of the variableName argument. You can use one of the following formats:
Table 11 describes the startSubscript and endSubscript arguments.
Specifying Arguments When Declaring an ArrayThe startSubscript argument is optional. If you do not specify it, then Siebel VB uses zero as the default value. For example, the following statement creates an array named counter that includes elements 0 through 25, for a total of 26 elements. To change the default value, you can use the Set Array Lower Boundary statement: The values in the startSubscript argument and the endSubscript argument are valid subscripts for the array. Size Limits of an ArrayYou can specify no more than 60 arrays in a parent array. The maximum total number of elements cannot exceed 65,536. For example, the following code is valid because 60 multiplied by 1092 is 65,520, which is less than 65,536: The following code is not valid because 60 multiplied by 1093 is 65,580, which is more than 65,536: Each subscript declares one array in the parent array. If you do not specify the subscriptRange argument, then Siebel VB declares the array as a dynamic array. In this situation, you must use the Declare Array method to specify the dimensions of the array before you can use it. Declaring a Number VariableTo declare a numeric variable, you can use the As clause and one of the following numeric types: To declare a numeric variable, you can also include a type character as a suffix to the variable name. Siebel VB sets a numeric variable to 0. Declaring a Record VariableTo declare a record variable, you use the As clause and specify a value in the typeName argument. To define this type, you must use the Type statement before you can specify it in the typeName argument. You use the following format: A record includes a collection of data elements that are fields. Each field can be a numeric, string, variant, or previously defined record type. For more information on accessing fields in a record, see Create Function Method. Declaring a String VariableSiebel VB supports the following types of strings:
Declaring a Variant VariableYou declare a variable as a variant in the following situations:
To declare a variant variable, you use one of the following formats:
Siebel VB initializes a variant variable to the Empty variant type. For more information, see Variants. Declaring an Object VariableTo declare an object variable, you use the As clause and specify a class in the typeName argument. An object variable can reference an object. To access members and methods of this object, it can use dot notation. For example:
For some classes, you can declare an object as New. For example:
In this situation, a Set statement is not required. Siebel VB allocates a new object when it uses this variable. NOTE: You cannot use the New operator with the Basic Object class. Caution About Declaring Multiple Variables on One LineCAUTION: Although you can declare multiple variables on one line, unless you include the type for each variable, Siebel VB applies the type of the last variable to all the variables that you declare on this line. For example, the following code declares all the variables as strings:
Shared Keyword Allows Backward CompatibilityTo allow backward compatibility with older versions of Visual Basic, Siebel VB includes the Shared keyword. You cannot use it in a Declare Variable statement in a procedure. If you use the Shared keyword in a Declare Variable statement in a procedure, then it has no effect. |
![]() |
![]() |
| Siebel VB Language Reference | Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |