3Using Siebel VB
Using Siebel VB
This chapter describes how to use Siebel VB. It includes the following topics:
For information about the format that Siebel VB uses, see the topic that describes the format of the object interface method in Siebel Object Interfaces Reference.
Guidelines for Using Siebel VB
This topic describes guidelines that you can use when you program with Siebel VB. It includes the following topics:
Pass Values Through Reference
Where possible, it is recommended that you pass a value through a reference and not through a variable. Passing a value through a variable is less efficient then passing the same value through a reference. You must write code that passes a value through a variable unless it cannot pass the same value through a reference.
Passing a Value Through a Reference
Siebel CRM can pass a variable to a subroutine or a function through a reference. Each method determines if it can receive a value from a variable or a reference. A subroutine or function can modify this value.
Passing a Value Through a Variable
Siebel CRM can pass a value to a function through a variable. After processing is complete, the variable retains the value that it contained before Siebel CRM passed it, even though the subroutine or function might modify the passed value.
If you configure Siebel CRM to pass a variable to a method that modifies the corresponding argument, and if you must retain the value that this variable contains, then you must enclose the variable in parentheses in the Call Subroutine statement. This format instructs Siebel VB to pass a copy of the variable. This technique is known as passing a value through a variable. For more information, see Call Subroutine Method.
If Siebel CRM passes a variable to a function, and if an argument for this function expects to receive a value through a reference, then this variable must match the exact type of the argument. This requirement does not apply to an expression or a variant.
If you configure Siebel CRM to call an external DLL, then you can configure the ByVal keyword to pass an argument through a value. You specify this configuration in the Declare Procedure statement or in the Call Subroutine statement. If you specify the ByVal keyword in the declaration, then the ByVal keyword is optional in the call. If you use the ByVal keyword, then it must precede the value. If you do not specify the ByVal keyword in the declaration, and if you specify the data type in the declaration, then you cannot use the ByVal keyword in the call.
For more information, see Declare Procedure Method.
Give Each Argument a Name
If you use a function that includes an argument, then you can provide a value for this argument. To do this, you list it in the order where it occurs in the format for the function. For example, assume you define the following function:
myfunction(id, action, value)
In this example, the myfunction function requires the following arguments:
id
action
value
If you call this function, then you specify these arguments in the order that they occur. If a function includes multiple arguments, then it is recommended that you name each argument. This technique helps to make sure that Siebel CRM assigns each value that you specify to the correct argument.
If you give each argument a name, then you are not required to remember the order where the arguments occur. For example, the following format is correct even though the order varies from the order that the format specifies:
myfunction action:="get", value:=0, id:=1
Consider the following code:
Sub mysub(aa, bb, optional cc, optional dd)
The following calls to this code are equivalent to each other:
call mysub(1, 2, , 4) mysub aa := 1, bb := 2, dd := 4 call mysub(aa := 1, dd:= 4, bb := 2) mysub 1, 2, dd:= 4
Format That You Can Use to Name an Argument
To name an argument, you use the following format:
argname:= argvalue
where:
argname is the name of the argument that you specify in the Function statement or the Sub statement. For more information, see Create Function Method and Create Subroutine Method.
argvalue is the value that Siebel CRM assigns to the argument when your code calls it.
For example:
myfunction id:=1, action:="get", value:=0
Naming an Argument With More Complex Formats
With some formats, you must use a comma as a placeholder for each optional argument that you do not specify. If you name the arguments, then you can specify only the arguments that your code must use and their values. For example, consider the following code:
myfunction(id, action, value, Optional counter)
In this situation, you can use one of the following formats:
myfunction id:="1", action:="get", value:="0"
myfunction value:="0", counter:="10", action:="get", id:="1"
You cannot omit a required argument.
Where You Can Name an Argument
You can name an argument in the following situations:
Functions you define with the Function statement
Subroutines you define with the Sub statement
Code that you declare with the Declare Procedure statement
Some predefined functions and statements
Some externally registered DLL functions and methods
Other Guidelines
It is recommended that you apply the following guidelines when you use Siebel VB. For information about each of them, see the topic about guidelines for using Siebel VB and Siebel eScript in Siebel Object Interfaces Reference:
Declare your variables
Use a standard naming convention
Use a self-reference to identify the current object
Avoid nested If statements
Use a four-digit year
Apply multiple object interface methods to a single object
Write code that handles run-time errors
About Data Types
This topic describes the data types that Siebel VB uses. It includes the following topics:
Overview of Data Types
Siebel VB is a strongly typed language. A variable can contain data only of the declared type. It supports numeric, string, record, and array data that is standard with the Visual Basic programming language. It supports the following data types:
Array
Double-precision, floating-point number
Double-precision integer
Integer
Object
Record
Single-precision, floating-point number
String
Variant
You can do one of the following to declare a variable:
You can use a type character to implicitly declare a variable the first time your code references it. If you do not use a type character, then Siebel VB uses a default type of Variant.
You can use the Declare Variable statement to explicitly declare the variable type. For more information, see Declare Variable Statement.
Arrays
To create an array, you specify one or more subscripts when you declare the array or when the Declare Array method redimensions the array. A subscript specifies the beginning and ending index for each dimension. If you specify only an ending index, then the beginning index depends on the Set Array Lower Boundary method. To reference an array element, you enclose each index value in parentheses after the array name. For example, the following format describes an array that includes three dimensions:
arrayName(i,j,k)
You can use an array with the following data types:
Number
String
Variant
Record
Object
Siebel VB does not support the following items:
An array of arrays
Dialog box records
Dialog box objects
For more information, see the following topics:
For examples that use arrays, see the following topics:
Dynamic Arrays
If you declare a dynamic array, then you do not specify a subscript range for the array elements. You can use the Declare Array method to set the subscript range. You can write code that sets the number of elements in a dynamic array according to other conditions that your code specifies. For example, you might use an array to store a set of values that the user enters, but you might not know in advance how many values the user will enter. In this situation, you can do one of the following:
Dimension the array without specifying a subscript range, and then run a Declare Array method each time the user enters a new value.
Write code that prompts the user to enter the number of values, and then run one Declare Array method to set the size of the array.
If you use the Declare Array method to modify the size of an array, and if you must preserve the contents of this array, then make sure you include the following Preserve argument in the Declare Array method:
Redim Preserve ArrayName(n)
If you use a Declare Variable statement to declare a dynamic array, then it can include no more than eight dimensions. You must use the Declare Array method to create a dynamic array that includes more than eight dimensions. This method allows you to declare an array that includes up to 60 dimensions. For more information, see Declare Variable Statement and Declare Array Method.
You cannot use the Declare Array method to modify the number of dimensions of a dynamic array if the array already has dimensions. It can modify only the upper and lower boundaries of the dimensions of the array. For information about methods that can determine the current boundaries of an array, see Get Array Lower Boundary Method and Get Array Upper Boundary Method.
Example of a Dynamic Array
The following example code uses a dynamic array named varray to hold the cash flow values that the user enters:
Sub main Dim aprate as Single Dim varray() as Double Dim cflowper as Integer Dim msgtext as String Dim x as Integer Dim netpv as Double cflowper=2 ReDim varray(cflowper) For x= 1 to cflowper varray(x)=500 Next x aprate=10 If aprate>1 then aprate=aprate/100 End If netpv=NPV(aprate,varray()) msgtext="The net present value is: " msgtext=msgtext & Format(netpv, "Currency") TheApplication.raiseErrorText msgtext End Sub
Numeric Data Types That Siebel VB Uses
The following table describes the numeric data types that Siebel VB uses.
Type | Description | Smallest Value | Largest Value |
---|---|---|---|
Integer |
2 byte integer |
Negative 32,768. |
Positive 32,767. |
Long |
4 byte integer |
Negative 2,147,483,648. |
Positive 2,147,483,647. |
Single-Precision |
4 byte floating-point number |
Negative 3.402823e+38 0.0, 1.401298e-45. |
Negative 1.401298e-45, 3.402823466e+38. |
Double-Precision |
8 byte floating-point number |
Negative 1.797693134862315d+308, 0.0, 2.2250738585072014d-308. |
Negative 4.94065645841247d-308, 1.797693134862315d+308. |
Currency |
8 byte number with a fixed decimal point |
Negative 922,337,203,685,477.5808. |
Positive 922,337,203,685,477.5807. |
A numeric value is always signed.
You can write code that expresses an integer constant in the following ways:
Decimal. You can use the decimal representation to express a decimal constant.
Octal. You precede the constant with &O or with &o to express an octal value. For example, &o177.
Hexadecimal. You precede the constant with &H or with &h to express a hexadecimal value. For example, &H8001.
For more information, see Boolean Data Type.
Records
A record is a data structure that includes one or more elements. Each of these elements includes a value. You must define a type first, and then declare the variable using that type. You must not include a type character as the suffix in the variable name. A record element uses dot notation. For example:
record.element
where:
record is the record name.
element is a member of this record. A record can contain elements that are themselves records.
Strings
A Siebel VB string can be one of the following:
Fixed. You specify the length when you define the string. You cannot write code that modifies the length after it defines the string. A fixed string cannot be of 0 length.
Dynamic. You do not specify a length. A dynamic string can vary in length from 0 to 32,767 characters.
There are no restrictions on the characters that a string can include. For example, a string can include a character whose ANSI value is 0.
You can cut and paste a character or you can use the Chr function to include a character from a character set. You can use characters only from the current character set. For more information, see Get ANSI String Method.
If you configure Siebel CRM to exchange data with another application, then you must consider how this application handles terminating characters. Some applications create and expect only a carriage return. To stop output text, Siebel VB uses a carriage return and a line feed (CRLF). It expects CRLF characters in input text unless this input is specifically configured for some input functions.
Variants
To define a variable that contains any type of data, you can write code that uses the variant data type. To identify the type of data that the variable currently contains, Siebel VB stores a tag with the variant data. To examine this tag, you can use the VarType function.
The following table describes the types of values that a variant can contain.
Type | Size of Data | Smallest Value | Largest Value |
---|---|---|---|
0 Empty |
0 |
Not applicable. |
Not applicable. |
1 Null |
0 |
Not applicable. |
Not applicable. |
2 Integer |
2 bytes, short |
Negative 32768. |
Positive 32767. |
3 Long |
4 bytes, long |
Negative 2.147E9. |
Positive 2.147E9. |
4 Single |
4 bytes, float |
Negative 3.402E38. |
Negative 1.401E-45. |
Positive 1.401E-45. |
Positive 3.402E38. |
||
5 Double |
8 bytes, double |
Negative 1.797E308. |
Negative 4.94E-324. |
Positive 4.94E-324. |
Positive 1.797E308. |
||
6 Currency |
8 bytes, fixed |
Negative 9.223E14. |
Positive 9.223E14. |
7 Date |
8 bytes, double |
Jan 1, 100 to Dec 31, 9999. |
Not applicable. |
8 String |
up to 2 gigabytes |
Length is limited by the amount of random access memory, up to 2 gigabytes. |
Not applicable. |
9 Object |
Not applicable. |
Not applicable. |
Not applicable. |
If you define a variant that contains no data, then Siebel VB defaults the type to Empty. It does the following:
Converts an empty variant to zero when it uses this variant in a numeric expression
Converts an empty variant to an empty string when it uses this variant in a string expression
You can use the IsEmpty statement to determine if a variant is empty. For more information, see Is Variable Set Method.
A null variant does not include data. It only represents a result that is not valid or that is ambiguous. You can use the IsNull statement to determine if a variant contains a null value. Null indicates that a variant is not set. For more information, see Is Variable Null Method.
Type Characters
Siebel VB can use a special character as the suffix of the name of a function, variable, or constant. This character identifies the data type of the variable or function. It is a declaration.
The following table lists the characters you can use as a suffix.
Data Type | Suffix |
---|---|
Dynamic String |
$ |
Integer |
% |
Long Integer |
& |
Single-precision floating-point |
! |
Double-precision floating-point |
# |
Currency, exact fixed point |
@ |
How Siebel VB Converts Data Types
This topic describes the conversions that occur between the data types that Siebel VB supports. It does not support any other conversions. It does not automatically do conversions between numeric and string data:
You can use the Val statement to convert a string to numeric data. For more information, see Get First Number From String Method.
You can use the Str statement to convert numeric data to a string. For more information, see Convert Number to String Method.
Numeric Conversion
If Siebel VB converts data from a larger number type to a smaller number type, then a run-time numeric overflow might occur. This situation indicates that the value of the larger type is too large for the target data type. Imprecision is not a run-time error. For example, when converting from double to single, or from float to a larger or a smaller type. Converting a long number to an integer is an example of converting a larger type to a smaller type.
String Conversion
If Siebel VB converts data from a fixed string to a dynamic string, then it creates a dynamic string that includes the same length and contents as the fixed string. If it converts a dynamic string to a fixed string, then it does the following work:
If the dynamic string is shorter than the fixed string, then it extends the fixed string with spaces.
If the dynamic string is longer than the fixed string, then it truncates the fixed string.
A string conversion does not cause run-time errors.
Variant Conversion
Siebel VB can convert data between any data type and a variant. It can convert a variant string to a number. If the variant string does not contain a valid representation of the number, then a type mismatch error occurs.
Comments
An apostrophe precedes a comment. It can occur on a separate line in the code or immediately after a statement or function on the same line. For example:
' This comment is on its own line Dim i as Integer ' This comment is on the code line
You can also use a Rem Statement to make a comment. For example:
Rem This is a comment line.
Siebel VB does not include a block comment feature.
About Expressions
An expression is a collection of two or more terms that perform a mathematical or logical operation. The terms are typically variables or functions that you use with an operator to evaluate to a string or numeric result. You can use an expression to perform a calculation, manipulate a variable, or concatenate a string.
Siebel VB evaluates an expression according to precedence order. You can use parentheses to override the default precedence order. The following operators are listed in order of highest precedence to lowest precedence:
Numeric Operators
Operator | Description |
---|---|
^ (caret) |
Exponentiation. |
- (minus) or + (plus) |
Unary minus and plus. |
* (asterisk) or / (forward slash) |
Numeric multiplication or division. For division, the result is a Double. |
\ (backward slash) |
Integer division. The operands can be Integer or Long. |
Mod |
Modulus or Remainder. The operands can be Integer or Long. |
- (minus) or + (plus) |
Numeric addition and subtraction. You can also use the + (plus) operator for string concatenation. |
String Operators
Operator | Description |
---|---|
& (ampersand) |
String concatenation |
+ (plus) |
String concatenation |
Comparison Operators
The following table describes comparison operators. For a number, Siebel VB increases the operands to the least common type:
Integer is preferable to Long.
Long is preferable to Single.
Single is preferable to Double.
For a string, the comparison is case-sensitive and is according to the collating sequence that the language specifies in the Microsoft Windows Control Panel. The result is 0 for FALSE and negative 1 for TRUE.
Operator | Description |
---|---|
> |
Greater than. |
< |
Less than. |
= |
Equal to. |
<= |
Less than or equal to. |
>= |
Greater than or equal to. |
<> |
Not equal to. |
Logical Operators
The following table describes logical operators. Siebel VB performs a bitwise operation for each operator.
Operator | Type | Description |
---|---|---|
NOT |
Unary Not |
Operand can be Integer or Long. |
AND |
And |
Operands can be Integer or Long. |
OR |
Inclusive Or |
Operands can be Integer or Long. |
XOR |
Exclusive Or |
Operands can be Integer or Long. |
EQV |
Equivalence |
Operands can be Integer or Long. (A EQV B) is the same as (NOT (A XOR B)). |
IMP |
Implication |
Operands can be Integer or Long. (A IMP B) is the same as ((NOT A) OR B). |
About Object Handling
An object is a reusable block of code. You can write code that instantiates an object or that does something. Each software application includes a set of properties and methods that modify the characteristics of an object.
A property affects how an object behaves. For example:
Width is a property of a range of cells in a spreadsheet.
Color is a property of a graph.
Margin is a property of a word processing document.
A method causes an application to perform an action on an object. For example:
Calculate for a spreadsheet
Snap to Grid for a graph
Auto-Save for a document
You can write Siebel VB that accesses a Siebel object and that modifies the properties and methods of this object. To access an object that is part of the Siebel application, you can run Siebel VB code that is external to the Siebel application.
To use a non-Siebel object in Siebel VB code, you must first assign it to an object variable. Assigning it instantiates it. To manipulate the object, you then reference the object name with or without properties and methods.
Example of Declaring an Object As a Siebel CRM Object Type
The following image includes an example that configures Siebel VB to access a Siebel object. You can declare an object as a Siebel CRM object type.

Explanation of Callouts
To declare an object as a Siebel CRM object type, you do the following work:
You create an object variable to access the code. This example uses as BusComp to declare the object. It does not use as Object. This example instantiates the business component (BusComp) Siebel object type. You could declare it as an object, but if you use the methods associated with the object type, then you must declare it as the appropriate object type.
You can use methods and properties to manipulate the objects.
Set oBC to nothing. It is recommended that you always set an object to nothing when your code instantiates it.
You can use similar code to access other types of objects that are compliant with COM. You can use the software application that creates the object to modify properties and methods of the objects. For an example, see Date and Time Methods.
Creating an Object Variable to Access an Object
The Declare Variable statement creates an object variable named oBC and assigns a picklist business component to this variable. The Assign COM Object statement uses a get method to assign the business component to the oBC variable. Note the following:
If you instantiate an application, then you can use the GetObject method or the CreateObject method.
If the application is already open on the Microsoft Windows desktop, then you use GetObject.
If the application is not open, then you can use CreateObject.
For more information, see the following topics:
Using Methods and Properties to Manipulate an Object
You can use the following format to access an object, property, or method:
appvariable.object.property appvariable.object.method
For example, the GetPickListBusComp method of the BusComp object of the Siebel application is assigned to the oBC object variable. It returns the following value:
me.GetPickListBusComp(“Sales Stage")
Declaring Procedures and Variables
This topic describes information about declaring procedures and variables.
Declaring a Procedure
This topic includes information about how to use the Declare Procedure statement to declare a procedure in a module or in a dynamic link library (DLL). For more information about this statement and the format and arguments that you can use with it, see Declare Procedure Method.
Specifying the Data Type
You do one of the following to specify the data type for the value that a method returns:
End the method name with a type character.
-
Use the following clause:
As funcType
Note the following:
If you do not specify a type, then the method that the Declare Procedure statement declares defaults to the data type variant.
To use a record argument, you use an As clause and a type that is already defined with the Type statement.
To use an array argument, you use empty parentheses after the argument. You do not specify an array dimension in the Declare Procedure statement.
Sequence Determines How You Must Declare Code
Sub A ' Calling B B End Sub
Sub B theApplication.RaiseErrorText "Sub B called" End Sub
Unknown function: B
Declare Sub B
Calling External DLL Code
You can use the Pascal calling convention to write code that calls external DLL code. Siebel VB pushes the arguments on the stack from left to right. It uses the Far reference to pass these arguments, by default. You can write code that uses the following keywords when it calls external DLL code:
-
ByVal. Passes a value through a variable. Note the following:
You must specify ByVal before you specify the argument that it modifies.
If you apply ByVal to a numeric data type, then Siebel VB passes the argument through a variable, not through a reference.
If you apply ByVal to a string data type, then Siebel VB passes the byFar pointer to the string data. It uses the byFar pointer to pass a string to a string descriptor, by default.
For more information, see Pass Values Through Reference.
-
Any. Passes a value of any datatype. If you use Any for an argument, then Siebel VB does not examine the type of this argument. It does examine the type of any other argument that you do not specify as type Any. It uses the Far reference to pass the argument unless you specify the ByVal keyword. If you specify the ByVal keyword, then it does one of the following:
Numeric data. Places the value on the stack.
String data. Sets the pointer to the string.
The external DLL code must determine the type and size of the value.
If Siebel VB uses ByVal to pass a null string, then the external code receives a nonNULL character of 0. To send a NULL pointer, you must declare the argument as ByVal As Any, and then call the code with an argument of 0.
Declaring Variables
This 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 Scope
You can write code that shares a variable across modules. The following locations where you declare a variable determines the scope of the variable:
Declare in a procedure. The variable is local to this procedure.
Declare outside a procedure. The variable is local to the module.
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 Variable
You can specify one of the following types when you declare a variable:
Arrays
Numbers
Records
Strings
Variants
Objects
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 Variable
The following data types are available for an array:
Numbers
Strings
Variants
Records
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:
Dim variable([[startSubcript To] endSubscript, ...]) As typeName
Dim variable_with_suffix([[startSubcript To] endSubscript, ... ])
The following table describes the startSubscript and endSubscript arguments.
Argument | Description |
---|---|
startSubscript |
The index number of the first array element, followed by the following keyword: To |
endSubscript |
The index number of the last element of the array. |
Specifying Arguments When Declaring an Array
The 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. You can use the Set Array Lower Boundary statement to modify the default value:
Dim counter (25) as Integer
The values in the startSubscript argument and the end Subscript argument are valid subscripts for the array.
Size Limits of an Array
You 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:
Dim count(1 To 60, 1 To 1092)
The following code is not valid because 60 multiplied by 1093 is 65,580, which is more than 65,536:
Dim count(1 To 60, 1 To 1093)
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 Variable
Can use the As clause and one of the following numeric types to declare a numeric variable:
Currency
Integer
Long
Single
Double
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 Variable
You 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:
Dim variableName As typeName
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 Variable
Siebel VB supports the following types of strings:
-
Fixed-length. Declared with a specific length between 1 and 32767. You cannot write code that modifies a fixed-length variable after you declare it. When you create a fixed-length string, Siebel VB fills it with zeros. To declare a fixed-length string, you use the following format:
Dim variableName As String * length
Dynamic. Does not include a declared length. It can vary in length from 0 to 32,767. The initial length for a dynamic string is 0. You can use one of the following formats to declare a dynamic string:
Dim variableName$ Dim variableName As String
Declaring a Variant Variable
You declare a variable as a variant in the following situations:
If the type of the variable is not known.
If Siebel CRM might modify the variable type when the code runs. For example, a variant is useful for holding input from a user when valid input can include text or numbers.
You use one of the following formats to declare a variant variable:
Dim variableName Dim variableName As Variant
Siebel VB initializes a variant variable to the Empty variant type.
For more information, see Variants.
Declaring an Object Variable
To 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:
Dim COMObject As Object Set COMObject = CreateObject("spoly.cpoly") COMObject.reset
You can declare an object as New for some classes. For example:
Dim variableName As New className variableName.methodName
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 Line
For example, the following code declares all of the following variables as strings:
Dim Acct, CustName, Addr As String
About Formatting Strings
This topic includes information about how to use the Set String Format method to format an output string. It includes the following topics:
For more information, see Set String Format Method.
Numeric Formats
This topic describes numeric formats that you can use with the Set String Format method.
Predefined Numeric Formats
The following table describes the predefined numeric formats that you can use.
Format | Description |
---|---|
General Number |
Displays the number without a thousand separator. |
Fixed |
Displays the number with at least one digit to the left and at least two digits to the right of the decimal separator. |
Standard |
Displays the number with a thousand separator and two digits to the right of decimal separator. |
Scientific |
Displays the number using standard scientific notation. |
Currency |
Displays the number using a currency symbol as defined in the International section of the Control Panel. Uses a thousand separator and displays two digits to the right of decimal separator. Encloses negative value in parentheses. |
Percent |
Multiplies the number by 100 and displays it with a percentage symbol (%) appended to the right. Displays two digits to the right of the decimal separator. |
True or False |
Displays FALSE for 0, or TRUE for any other number. |
Yes or No |
Displays No for 0, or Yes for any other number. |
On or Off |
Displays Off for 0, or On for any other number. |
Custom Numeric Formats
You can use one or more digit characters to create a simple custom numeric format. You can use the following digit characters:
0 (zero). Displays a corresponding digit in the output.
(#) number sign. If the digit is significant, then it displays it in the output. A significant digit is a digit that resides in the middle of the number or is not zero.
The following table includes examples of using zero and the number (#) sign.
Number | Format | Result |
---|---|---|
1234.56 |
# |
1235 |
1234.56 |
#.## |
1234.56 |
1234.56 |
#.# |
1234.6 |
1234.56 |
######.## |
1234.56 |
1234.56 |
00000.000 |
01234.560 |
0.12345 |
#.## |
.12 |
0.12345 |
0.## |
0.12 |
You can use a decimal separator as an option.
A comma instructs Siebel VB to place a comma between every three digits that occur to the left of the decimal separator.
The following table includes examples of using a comma.
Number | Format | Result |
---|---|---|
1234567.8901 |
#,#.## |
1,234,567.89 |
1234567.8901 |
#,#.#### |
1,234,567.8901 |
Siebel VB uses the current international settings for your computer to determine the character to display for a comma or a period. For example, some locales use a period as the decimal separator. Other locales use a comma.
Scaling Numbers
Insert one or more commas before the decimal separator. Each comma that precedes the decimal separator divides the number by 1000. if you do not specify a decimal separator, then this configuration applies to all digits. Siebel CRM does not include a comma in the output string.
Include a percentage symbol (%) in the format argument. A percentage symbol multiplies the number by 100. Siebel CRM includes the percentage symbol in the output string in the same position where it occurs in the format argument.
The following table includes examples of using a comma or a percentage symbol to scale numbers.
Number | Format | Result |
---|---|---|
1234567.8901 |
#,.## |
1234.57 |
1234567.8901 |
#,,.#### |
1.2346 |
1234567.8901 |
#,#,.## |
1,234.57 |
0.1234 |
#0.00% |
12.34% |
Inserting Characters In Number Formats
To insert a character in a number in the output string, you enclose the character in double quotes in the format argument. You can also insert a set of characters. Siebel VB inserts the following characters in the output string in a location that matches the position in the format argument:
- + $ ( space
You can precede the character with a backslash (\) to insert a single character.
The following table includes examples of using double quotes and backslahes to insert characters.
Number | Format | Result |
---|---|---|
1234567.89 |
$#,0.00 |
$1,234,567.89 |
1234567.89 |
"TOTAL:" $#,#.00 |
TOTAL: $1,234,567.89 |
1234 |
\ = \>#,#\<\ = |
= >1,234< = |
You can use the Get ANSI String method to insert a quotation mark (") in a format argument. The character code for a quotation mark is 34. For more information, see Get ANSI String Method.
Scientific Notation Formats
E-
E +
e-
e +
An uppercase e. An uppercase e displays in the output.
A lowercase e. A lowercase e displays in the output.
A minus sign that follows an uppercase e. A minus sign precedes any negative exponent that displays in the output.
A plus sign. A sign always precedes the exponent in the output.
You precede the exponent string with one or more digit characters. The number of digit characters that following the exponent string determines the number of exponent digits that occur in the output.
Number | Format | Result |
---|---|---|
1234567.89 |
###.##E-00 |
123.46E04 |
1234567.89 |
###.##e + # |
123.46e + 4 |
0.12345 |
0.00E-00 |
1.23E-01 |
Using Sections In a Numeric Format
A numeric format can include up to four sections. A semicolon (;) separates each section. The format varies depending on the number of sections you specify:
One section. This section applies to every value.
-
Two sections:
The first section applies to positive values and zeros.
The second section applies to negative values.
-
Three sections:
The first section applies to positive values.
The second section applies to negative values.
The third section applies to zeros.
If you include semicolons with nothing between them, then Siebel VB uses the format of the first section to print the undefined section.
Four sections. Same as three sections, except the fourth section applies to Null values. If you do not include the fourth section, and if the input expression results in a NULL value, then Siebel VB returns an empty string.
The following table includes examples of using sections.
Number | Format | Result |
---|---|---|
1234567.89 |
#,0.00;(#,0.00);"Zero";"NA" |
1,234,567.89 |
-1234567.89 |
#,0.00;(#,0.00);"Zero";"NA" |
(1,234,567.89) |
0.0 |
#,0.00;(#,0.00);"Zero";"NA#" |
Zero |
0.0 |
#,0.00;(#,0.00);;"NA" |
0.00 |
Null |
#,0.00;(#,0.00);"Zero";"NA" |
NA |
Null |
"The value is: " |
0.00 |
Date and Time Formats
This topic describes date and time formats that you can use with the Set String Format method. For more information, see Set String Format Method.
Predefined Date and Time Formats
The following table describes predefined date and time formats that you can use.
Format | Description |
---|---|
General Date |
Note the following:
|
Long Date |
Displays a long date. The International section of the Control Panel defines a long date. |
Medium Date |
Displays the date using the month abbreviation without the day of the week. For example, 08-Nov-2011. |
Short Date |
Displays a short date. The International section of the Control Panel defines a short date. |
Long Time |
Displays a long time. The International section of the Control Panel defines a long time. It includes hours, minutes, and seconds. |
Medium Time |
Does not display seconds. It displays hours in a 12 hour format and uses the AM and PM designator. |
Short Time |
Does not display seconds. It uses a 24 hour format and does not use the AM and PM designator. |
Custom Date Formats
You can use a series of tokens in the format argument to define a custom format for a date. Siebel VB replaces each token in the output string with an appropriate corresponding value.
The following table describes the tokens that you can use.
Token | Output |
---|---|
c |
The equivalent of the format ddddd ttttt. |
ddddd |
The current date, including the day, month, and year according to the current Short Date setting of the computer. The following format is the default Short Date setting for the United States: m/d/yy |
dddddd |
The current date, including the day, month, and year according to the current Long Date setting of the computer. The following format is the default Long Date setting for the United States: mmmm dd, yyyy |
ttttt |
The current time, including the hour, minute, and second using the current time settings of the computer. The following format is the default time setting for the United States: h:mm:ss AM/PM |
Specifying Individual Parts of a Custom Date Format
The following table describes the tokens that you can use to specify individual parts of a custom date format.
Token | Output |
---|---|
d |
The day of the month as a one or two digit number in the range of 1 through 31. |
dd |
The day of the month as a two digit number in the range of 1 through 31. |
ddd |
The day of the week as a three letter abbreviation in the range of Sun through Sat. |
dddd |
The day of the week without abbreviation in the range of Sunday through Saturday. |
w |
The day of the week as a number, where Sunday is 1 and Saturday is 7. |
ww |
The week of the year as a number in the range of 1 through 53, where the first week of January is always week 1. |
m |
The month of the year or the minute of the hour as a one or two digit number:
|
mm |
The month or the year or the minute of the hour as a two digit number:
|
mmm |
The month of the year as a three letter abbreviation in the range of Jan through Dec. |
mmmm |
The month of the year without abbreviation in the range of January through December. |
q |
The quarter of the year as a number in the range of 1 through 4. |
y |
The day of the year as a number in the range of 1 through 366. |
yy |
The year as a two digit number in the range of 00 through 99. |
yyyy |
The year as a three digit or a four digit number in the range of 100 through 9999. |
h |
The hour as a one digit or a two digit number in the range of 0 through 23. |
hh |
The hour as a two digit number in the range of 00 through 23. |
n |
The minute as a one digit or a two digit number in the range of 0 through 59. |
nn |
The minute as a two digit number in the range of 00 through 59. |
s |
The second as a one digit or a two digit number in the range of 0 through 59. |
ss |
The second as a two digit number in the range of 00 through 59. |
Using a 12 Hour Format
The following table describes the tokens that you can use that use a 12 hour format. Siebel VB uses a 24 hour format, by default.
Token | Output |
---|---|
AM/PM |
This token displays the following formats:
|
am/pm |
This token displays the following formats:
|
A/P |
This token displays the following formats:
|
a/p |
This token displays the following formats:
|
AMPM |
This token displays the following formats:
|
Other Formatting Options
This topic describes other formatting options that you can use with the Set String Format method.
Changing Formatting Sequence
Siebel VB formats characters from left to right, by default. To format characters from right to left, you can include an exclamation point (!) in the format argument.
Changing Case
Siebel VB does not modify the case of characters that it formats, by default. To instruct Siebel VB to modify the case of a character, you can use the following characters:
< (Less than). Converts output characters to lowercase.
> (Greater than). Converts output characters to uppercase.
Handling Spaces That Occur in the Input String
The following table describes characters that you can use to handle spaces that occur in the input string.
Character | Description |
---|---|
@ |
Siebel VB displays a character or a space according to the following logic:
|
& |
Siebel VB displays a character or nothing according to the following logic:
|
About Error Handling
This topic describes error handling. It includes the following topics:
Overview of Error Handling
Siebel VB includes the following error handling statements and functions:
Err
Error
On Error
Siebel VB returns a code for many of the run-time errors that you might encounter. For more information, see Error Code and Error Text for Siebel VB Errors.
You can write code that uses the On Error statement in the following ways:
Add code that handles the error immediately before a line of code where an error might occur. For example, after a File Open statement.
Label a separate section of the code only for error handling and instruct Siebel VB to proceed to this label if an error occurs.
Handling Errors That Siebel VB Returns
This topic describe how to write code that handles the errors that Siebel VB returns.
Using the Body of the Code to Handle Siebel VB Errors
To handle errors in the body of code, you place the code that handles the error immediately before the line of code that could cause an error.
The following image includes an example that handles errors in the body of the code.

Explanation of Callouts
The example that handles errors in the body of the code includes the following items:
The On Error statement identifies the line of code to run if an error occurs.
The If statement handles the error. It uses the Err statement to identify the error that Siebel VB returns.
The Resume Next argument instructs Siebel VB to proceed to the next line of code after it handles the error.
Using an Error Handler to Handle Siebel VB Errors
The following image includes an example that uses an error handler to handle errors.

Explanation of Callouts
The example that uses an error handler to handle errors includes the following items:
The On Error statement identifies the line of code that Siebel CRM runs if an error occurs. The code segment is part of the main code and it uses the Err statement to determine the error code that Siebel VB returns.
You precede the code with an Exit statement to make sure that it does not accidentally proceed to the error handler.
Handling Custom Errors
You can create a custom set of error codes to handle errors that are specific to your code. For example, you can create your own set of error codes if your Siebel VB code creates rules for file input but the user does not follow these rules. You can configure Siebel VB to create an error and reply appropriately using the same statements and functions that you use for error codes that Siebel VB returns.
Using the Body of the Code to Handle Custom Errors
The following image includes an example that uses the body of the code to handle a custom error.

Explanation of Callouts
The example that uses the body of the code to handle a custom error includes the following items:
Place the code that handles the error immediately before the line of code that could cause an error.
You use the Error statement to set the custom error to a value of 30000.
Using a Label to Handle Custom Errors
The following image includes an example that uses a label to handle a custom error.

Explanation of Callouts
The example that uses a label to handle a custom error includes the following items:
Place the code that handles the error immediately before the line of code that could cause an error.
Use a labeled section of code to handle the custom error.
Handling Errors That a Siebel VB Method Returns
You must configure Siebel CRM to handle an error that a Siebel VB method returns differently from how you configure it to handle an error that a Visual Basic function or statement returns. You can use the following code to handle an error that a Siebel VB method creates. This code displays the text of the error message:
DisplayError: If ErrCode <> 0 Then ErrText = GetLastErrText TheApplication.RaiseErrorText ErrText Exit Sub End If
Note the following:
A Siebel VB method uses numeric error codes in the range of 4000 through 4999.
DisplayError is a label and is the target of a Go To statement that exists elsewhere in the code.
The GetLastErrText method is available only through an interface that is external to Siebel Tools. You can use it in Microsoft Visual Basic but not in Siebel VB.
For more information, see Siebel Object Interfaces Reference.
Error Code and Error Text for Siebel VB Errors
The following table lists the run-time errors that Siebel VB returns. The On Error statement can handle these errors. The Err function can query the error code and the Error function can query the error text. For more information, see the following topics:
Error Code | Error Text |
---|---|
5 |
Illegal function call |
6 |
Overflow |
7 |
Out of memory |
9 |
Subscript out of range |
10 |
Duplicate definition |
11 |
Division by zero |
13 |
Type Mismatch |
14 |
Out of string space |
19 |
No Resume |
20 |
Resume without error |
28 |
Out of stack space |
35 |
Sub or Function not defined |
48 |
Error in loading DLL |
52 |
Bad file name or number |
53 |
File not found |
54 |
Bad file mode |
55 |
File already open |
58 |
File already exists |
61 |
Disk full |
62 |
Input past end of file |
63 |
Bad record number |
64 |
Bad file name |
68 |
Device unavailable |
70 |
Permission denied |
71 |
Disk not ready |
74 |
Can't rename with different drive |
75 |
Path/File access error |
76 |
Path not found |
91 |
Object variable set to Nothing |
93 |
Invalid pattern |
94 |
Illegal use of NULL |
102 |
Command failed |
429 |
Object creation failed |
438 |
No such property or method |
439 |
Argument type mismatch |
440 |
Object error |
901 |
Input buffer is larger than 64K |
902 |
Operating system error |
903 |
External procedure not found |
904 |
Global variable type mismatch |
905 |
User-defined type mismatch |
906 |
External procedure interface mismatch |
907 |
Pushbutton required |
908 |
Module has no MAIN |
910 |
Dialog box not declared |