Bookshelf Home | Contents | Index | PDF |
Siebel VB Language Reference > Using Siebel VB > 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 that 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 write code that shares 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 VariableYou can specify one of the following types when you declare a variable: 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 write code that omits the type character when your code references the variable. 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 write code that uses the Declare Variable statement to declare an array of arrays or an array of objects. You include a subscript list as part of the variableName argument to declare an array variable. 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 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 that resides 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 your code can use it. Declaring a Number VariableCan 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 to declare a numeric variable. Siebel VB sets a numeric variable to 0. Declaring a Record VariableYou can use the As clause and specify a value in the typeName argument to declare a record variable. 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:
You use one of the following formats to declare a variant variable:
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. It can use dot notation to access members and methods of this object. For example:
You can declare an object as New for some classes. For example:
A Set statement is not required in this situation. Siebel VB allocates a new object when it uses this variable. You cannot use the New operator with the Basic Object class. Caution About Declaring Multiple Variables on One LineCAUTION: You can declare multiple variables on one line. However, if you do not include the type for each variable, then 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 of the following variables as strings:
Shared Keyword Allows Backward CompatibilitySiebel VB includes the shared keyword to support backward compatibility with older versions of Visual Basic. 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 © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |