Iebel Usiness Pplications: S VBL R
Iebel Usiness Pplications: S VBL R
SIEBEL VB LANGUAGE
REFERENCE
SIEBEL 2000
VERSION 6.0
10PA1-VB00-06000
MARCH 2000
Siebel Systems, Inc., 1855 South Grant St., San Mateo, CA 94402
Copyright 2000 Siebel Systems, Inc.
All rights reserved. Published 19962000
Printed in the United States of America
No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including
but not limited to photocopy, photographic, magnetic or other record, without the prior agreement and written
permission of Siebel Systems, Inc.
Target Account Selling Methodologies, Copyright 1996 Target Marketing International, Inc. All rights reserved.
The full text search capabilities of Siebel eBusiness Applications include technology used under license from
Fulcrum Technologies, Inc. and are the copyright of Fulcrum Technologies, Inc. and/or its licensors.
Siebel, the Siebel logo, ActiveBriefing, TrickleSync, TSQ, Universal Agent, and other Siebel product names
referenced herein are trademarks of Siebel Systems, Inc., and may be registered in certain jurisdictions.
Windows is a registered trademark of Microsoft Corporation.
All other product names, marks, logos, and symbols may be trademarks or registered trademarks of their
respective owners.
U.S. GOVERNMENT RESTRICTED RIGHTS. Programs, Ancillary Programs and Documentation, delivered
subject to the Department of Defense Federal Acquisition Regulation Supplement, are commercial computer
software as set forth in DFARS 227.7202, Commercial Computer Software and Commercial Computer Software
Documentation, and as such, any use, duplication and disclosure of the Programs, Ancillary Programs and
Documentation shall be subject to the restrictions contained in the applicable Siebel license agreement. All
other use, duplication and disclosure of the Programs, Ancillary Programs and Documentation by the U.S.
Government shall be subject to the applicable Siebel license agreement and the restrictions contained in
subsection (c) of FAR 52.227-19, Commercial Computer Software - Restricted Rights (June 1987), or
FAR 52.227-14, Rights in General Data Alternative III (June 1987), as applicable. Contractor/licensor is
Siebel Systems, Inc., 1855 South Grant Street, San Mateo, CA 94402.
Proprietary Information
Siebel Systems, Inc. considers information included in this documentation and
in Siebel eBusiness Applications Online Help to be Confidential Information.
Your access to and use of this Confidential Information are subject to the terms
and conditions of: (1) the applicable Siebel Systems software license
agreement, which has been executed and with which you agree to comply; and
(2) the proprietary and restricted rights notices included in this documentation.
Contents
Introduction
Welcome to Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-2
Who Should Use This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-3
Supported Uses of Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-4
How This Guide Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-5
Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-6
Additional Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-7
Version 6.0
iii
Contents
iv
Version 6.0
Contents
. . . . . . . . . . . . . . . . 2-28
Version 6.0
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
vi
Version 6.0
Contents
BusComp_WriteRecord Event
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Version 6.0
vii
Contents
DeactivateFields Method
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97
vii i
Version 6.0
Contents
Version 6.0
ix
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-156
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-175
Version 6.0
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-211
Version 6.0
xi
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-249
xii
Version 6.0
Contents
PV Function
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-258
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
x iii
Contents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-328
xiv
Version 6.0
Contents
Version 6.0
xv
Contents
xvi
Version 6.0
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-7
Version 6.0
I n tr o - 1
Introduction
Welcome to Siebel VB
Welcome to Siebel VB
Intro
In t ro - 2
Version 6.0
Introduction
Who Should Use This Guide
Intro
Programmers with experience in other languages can use this and the related
volumes to become proficient in Siebel VB. Those with no programming experience
should turn to other sources for basic information about programming.
Version 6.0
I n tr o - 3
Introduction
Supported Uses of Siebel VB
Intro
This document describes the supported functionality of the Siebel VB language and
provides examples of how a Siebel developer will use Siebel VB. Siebel Enterprise
applications provide a high performance client/server application specifically
designed to meet the most rigorous sales and marketing information requirements
of large multi-national corporations. Caution should be exercised when extending
the Siebel Sales Enterprise application and should be done only by trained technical
professionals. Please keep in mind that improper application configuration can
adversely impact the reliability and performance characteristics of your configured
Siebel application. Thorough testing is strongly recommended before production
rollout of your configured application.
In summary Siebel supports:
In t ro - 4
Version 6.0
Introduction
How This Guide Is Organized
Intro
Version 6.0
I n tr o - 5
Introduction
Typographic Conventions
Typographic Conventions
Intro
Typographic Conventions
To Represent
Help Syntax Is
Arguments to statements or
functions
In t ro - 6
Version 6.0
Introduction
Additional Documentation
Additional Documentation
Intro
Version 6.0
I n tr o - 7
Introduction
Contacting Siebel Technical Support
Intro
Do you know how to access Siebel Technical Support? It is crucial that you
understand the requirements for getting support. This will ensure the best
experience possible. If you have questions, please dont hesitate to contact us.
To ensure that you maximize your knowledge of Siebel products and your return on
investment:
+44.1784.494.949
Tokyo:
+81.3.5469.3811(main number)
Munich:
+49.89.95718.400
In t ro - 8
Version 6.0
Introduction
Siebel Welcomes Your Comments
Intro
Version 6.0
I n tr o - 9
Introduction
Siebel Welcomes Your Comments
In t ro - 1 0
Version 6.0
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
1-1
This chapter lists the Siebel VB statements and functions by functional group.
Arrays
Statement
Function
Erase
LBound
ReDim
UBound
Compiler Directives
1-2
Statement
Function
Rem
'
Version 6.0
Control Flow
Version 6.0
Statement
Function
Call
Do...Loop
Exit
For...Next
Goto
If...Then...Else
Let
Lset
On...Goto
Rset
Select Case
Set
Stop
While...Wend
With
1-3
1-4
Statement
Function
Date Function
Date Statement
DateSerial
Returns the date value for year, month, and day specified
DateValue
Day
Hour
IsDate
Minute
Month
Now
Second
Time Function
Time Statement
Timer
TimeSerial
Returns the time value for hour, minute, and second specified
TimeValue
Weekday
Returns the day of the week for the specified date-time value
Year
Version 6.0
Declarations
Version 6.0
Statement
Function
Const
Declare
Deftype
Dim
Declares variables
Function...End Function
Defines a function
Global
Option Base
Option Compares
Option Explicit
ReDim
Static
Defines a subprogram
Type
1-5
Environment Control
Statement
Function
AppActivate
Command
Returns the command line specified when the MAIN sub was run
Beep
Date Statement
DoEvents
Environ
Randomize
SendKeys
Shell
Errors
1-6
Statement
Function
Erl
Err Function
Err Statement
Error Statement
Error Function
On Error
Resume
Trappable Errors
Version 6.0
Files
Statement
Function
ChDir
ChDrive
CurDir
Dir
MkDir
RmDir
File Control
Version 6.0
Statement
Function
FileAttr
Felicity
Copies a file
FileDateTime
FileLen
GetAttr
Kill
Name
SetAttr
1-7
File Input/Output
1-8
Statement
Function
Close
Closes a file
Eof
FreeFile
Get
Input Function
Input Statement
Line Input
Loc
Lock
Lof
Open
Put
Reset
Seek Function
Seek Statement
Spc
Tab
Unlock
Width
Writes
Version 6.0
Math Functions
Financial Functions
Statement
Function
FV
IPmt
IRR
NPV
Pmt
PPmt
PV
Rate
Numeric Functions
Version 6.0
Statement
Function
Abs
Exp
Fix
Int
IsNumeric
Log
Rnd
Sgn
Sqr
Derived
Functions
1-9
Trigonometric Functions
Statement
Function
Atn
Cos
Sin
Tan
Derived Functions
Objects
1-10
Statement
Function
Clipboard
CreateObject
GetObject
Retrieves a COM object from a file or get the active COM object for a
COM class
Is
Me
New
Nothing
Object
Typeof
With
Version 6.0
ODBC
Version 6.0
Statement
Function
SQLClose
SQLError
SQLExecQuery
SQLGetSchema
SQLOpen
SQLRequest
SQLRetrieve
SQLRetrieveToFile
1-11
Strings
String Functions
1-12
Statement
Function
GetField
Hex
InStr
LCase
Left
Len
Like Operator
LTrim
Mid Function
Mid Statement
Oct
Right
RTrim
SetField
Space
Str
StrComp
String
Trim
UCase
Version 6.0
String Conversions
Statement
Function
Asc
CCur
CDbl
Chr
CInt
CLng
CSng
CStr
CVar
CVDate
Format
Val
Variants
Version 6.0
Statement
Function
IsEmpty
IsNull
Null
VarType
1-13
1-14
Version 6.0
Language Overview
. . . . 2-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-12
Records
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
Type Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-14
Data Type Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
Dynamic Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16
Variant Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18
Numeric Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-19
String Operators
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19
Version 6.0
2-1
Language Overview
2-2
Version 6.0
Language Overview
Setting Up Microsoft Visual Basic to Access the Siebel Applications
References.
4 In the list box, highlight (but do not check) Siebel BusObject Interfaces.
5 Near the bottom of the dialog box, note the directory in which the file sappsrv.tlb
resides, as shown below.
Version 6.0
2-3
Language Overview
Setting Up Microsoft Visual Basic to Access the Siebel Applications
If the location is the same as that of the .cfg file, check the box and click OK.
You are finished.
If the location is not the same, proceed to Step 6.
6 In the Windows Explorer, open the directory containing the .cfg file to use. By
default, .cfg files should be in the bin directory.
7 Double-click the file sapptlb.reg. Repeat Step 4 and Step 5.
For more information on the COM interfaces, see the Siebel Object Interfaces
Reference.
2-4
Version 6.0
Language Overview
Getting Started with Siebel VB
If you have never programmed in Visual Basic before, you may find the following
hints helpful.
Declare your variables. As a general rule, it is helpful to use the Option Explicit
statement, which forces you to declare all your variables (using the Dim statement)
before you use them. Doing so makes it easier for others to understand your code,
and for you to debug the code. You can declare a variable without giving it a data
type; but if you dont specify a data type, Siebel VB will assume the type Variant,
which requires 16 bytestwice as much memory as the next smallest data type. If
you can avoid Variant variables, you will reduce the amount of memory required by
your code, which may make execution faster. In Siebel VB, you place Option
commands in the (general) (declarations) window.
Use standardized naming conventions. Another way to improve the readability of your
Symbol
Example
String
sName
Integer
iReturn
Long integer
lBigCount
Single-precision number
si
siAllowance
Double-precision number
dBudget
Object
oBusComp
Currency
cAmtOwed
You can also use suffix characters on your variable names, as described in Type
Characters on page 2-14.
Version 6.0
2-5
Language Overview
Getting Started with Siebel VB
The Me object reference. The special object reference Me is a VB shorthand for the
current object. You should use it in place of references to active Siebel business
objects. For example, in a business component event handler, you should use Me in
place of ActiveBusComp, as shown in the following example.
Function BusComp_PreSetFieldValue(FieldName As String, FieldValue As
String) As Integer
If Val(Me.GetFieldValue(Rep %)) >75 Then
....
End If
BusComp_PreSetFieldValue = ContinueOperation
End Function
Trap errors. Especially in a LAN environment, where you cannot be sure that a
record hasnt been changed or deleted by another user, its important to create
routines that will keep the program from failing when it meets an unexpected
condition. You will find information about error-handling routines in Error
Handling on page 2-24.
Make effective use of the Select Case construct. The Select Case construct allows the
program to choose among any number of alternatives your require, based on the
value of a single variable. It is greatly preferable to a series of nested If statements,
because it simplifies code maintenance, and also improves performance, because
the variable must be evaluated only once. For a full description, see the Select Case
Statement on page 3-288.
Use the With shortcut. The With statement (see page 3-372) allows you apply several
methods to a single object. It makes the code easier to read, reduces typing, and
improves performance. Instead of a series of statements such as
Set oBusComp = objBusObject.GetBusComp("Opportunity")
oBusComp.ClearToQuery
oBusComp.SetSearchSpec . . .
oBusComp.ExecuteQuery ForwardBackward
oBusComp.FirstRecord
oBusComp.NewRecord NewAfter
oBusComp.SetFieldValue "QuoteNumber", sQuoteId
oBusComp.SetFieldValue "Account", sAccount
2-6
Version 6.0
Language Overview
Getting Started with Siebel VB
. . .
sSolutionId(cSolution) = oBusComp.GetFieldValue( "Id" )
. . .
Use extreme care when working with date variables. When working with date
variables extreme care has to be taken regarding the date format. GetFieldValue
always returns the date in the format "dd/mm/yyyy" (eventually followed by the
time). As a result, applying the CVDate() function, which expects the regional
setting, to the return value may cause an error. The GetFormattedFieldValue method
uses the regional settings of the user's operating system. The regional settings
specify the year with two digits in most cases, thereby creating the possibility of
Y2K non-compliance For these reasons, you should use the following approach for
performing date arithmetic:
1 Retrieve the value of date fields with the GetFieldValue method (See the Siebel
Object Interfaces Reference).
2 Convert it into a date variable using the DateSerial function (see page 3-64).
3 perform the required date arithmetic.
Here is an example:
Dim strDate as String, varDate as Variant
strDate = oBC.GetFieldValue("Date Field")
varDate = DateSerial(Mid(strDate,7,4), Left(strDate,2), _
Mid(strDate,4,2))
[any date arithmetic]
Version 6.0
2-7
Language Overview
Conventions
Conventions
Arguments
Arguments to subprograms and functions you write are listed after the subroutine
or function and might or might not be enclosed in parentheses. Whether you use
parentheses depends on how you want to pass the argument to the subroutine or
function: either by value or by reference.
If an argument is passed by value, it means that the variable used for that argument
retains its value when the subroutine or function returns to the caller. If an
argument is passed by reference, it means that the variable's value might be (and
probably will be) changed for the calling procedure. For example, suppose you set
the value of a variable, x, to 5 and pass x as an argument to a subroutine, named
mysub. If you pass x by value to mysub, the value of x will always be 5 after mysub
returns. If you pass x by reference to mysub, however, x could be 5 or any other
value resulting from the actions of mysub.
To pass an argument by value, use one of the following syntax options:
Call mysub((x))
mysub(x)
y = myfunction((x))
Call myfunction((x))
2-8
Version 6.0
Language Overview
Conventions
functions.
Named Arguments
When you call a subroutine or function that takes arguments, you usually supply
values for those arguments by listing them in the order shown in the syntax for the
statement or function. For example, suppose you define a function this way:
myfunction(id, action, value)
From the above syntax, you know that the function called myfunction requires three
arguments: id, action, and value. When you call this function, you supply those
arguments in the order shown. If the function contains just a few arguments, it is
fairly easy to remember the order of each of the arguments. However, if a function
has several arguments, and you want to be sure the values you supply are assigned
to the correct arguments, use named arguments.
Named arguments are arguments that are identified by name rather than by position
in the syntax. To use a named argument, use the following syntax:
namedarg:= value
Version 6.0
2-9
Language Overview
Conventions
The advantage of named arguments is that you do not need to remember the
original order as they were listed in the syntax, so the following function call is also
correct:
myfunction action:="get", value:=0, id:=1
or
myfunction value:="0", counter:="10", action:="get", id:="1"
NOTE: Although you can shift the order of named arguments, you cannot omit
required arguments. All Siebel VB functions and statements accept named
arguments. The argument names are listed in the syntax for each statement and
function.
Comments
Comments are preceded by an apostrophe and can appear on their own line in a
procedure or directly after a statement or function on the same line:
' This comment is on its own line
Dim i as Integer ' This comment is on the code line
Comments are also indicated by the Rem statement.
2-10
Version 6.0
Language Overview
Data Types
Data Types
Arrays
Arrays are created by specifying one or more subscripts at declaration or when the
array is redimensioned by the ReDim statement (see the ReDim Statement on
page 3-263). Subscripts specify the beginning and ending index for each dimension.
If only an ending index is specified, the beginning index depends on the Option
Base setting. Array elements are referenced by enclosing the proper number of
index values in parentheses after the array name. For example, arrayName(i,j,k)
indicates an array with three dimensions. See the Dim Statement on page 3-73 for
more information.
For examples of the use of arrays, see the IsEmpty Function on page 3-175, IsNull
Function on page 3-179, NPV Function on page 3-227, Null Function on page 3-229,
Option Base Statement on page 3-241, and VarType Function on page 3-363.
Version 6.0
2-11
Language Overview
Data Types
Numbers
Numeric Types
Type
Description
From
To
Integer
2-byte integer
-32,768
32,767
Long
4-byte integer
-2,147,483,648
2,147,483,647
Single
-3.402823e+38
0.0,
1.401298e-45
-1.401298e-45,
-1.797693134862315d+308,
0.0,
2.2250738585072014d-308
-4.94065645841247d-308,
-922,337,203,685,477.5808
922,337,203,685,477.5807
Double
Currency
3.402823466e+38
1.797693134862315d+308
2-12
Version 6.0
Language Overview
Data Types
Records
where record is the previously defined record name and element is a member of that
record. Records can contain elements that are themselves records.
Strings
Siebel VB strings can be either fixed or dynamic. Fixed strings have a length
specified when they are defined, and the length cannot be changed. Fixed strings
cannot be of 0 length. Dynamic strings have no specified length. Any string can vary
in length from 0 to 32,767 characters. There are no restrictions on the characters
that can be included in a string. For example, the character whose ANSI value is 0
can be embedded in strings.
NOTE: You can use characters only from the current character set. Within a character
set, any character can be embedded either by cutting and pasting or by using the
Chr function. See the Chr Function on page 3-38.
Version 6.0
2-13
Language Overview
Data Types
Type Characters
Siebel VB permits the use of special characters as the suffix to the name of a
function, variable, or constant. The character defines the data type of the variable
or function, and operates as a de facto declaration. The type characters are shown
in Table 2-2.
2-14
Table 2-2.
Data Type
Suffix
Dynamic String
Integer
Long Integer
&
Single-precision floating-point
Double-precision floating-point
Version 6.0
Language Overview
Data Type Conversions
Numeric conversions. Siebel VB will automatically convert data between any two
numeric types. When converting from a larger type to a smaller type (for example
Long to Integer), a runtime numeric overflow might occur. This indicates that the
number of the larger type is too large for the target data type. Loss of precision is
not a runtime error (for example, when converting from Double to Single, or from
either float type to either integer type).
String conversions. Siebel VB will also automatically convert between fixed strings
and dynamic strings. When converting from a fixed a string to a dynamic string, a
dynamic string that has the same length and contents as the fixed string is created.
When converting from a dynamic string to a fixed string, some adjustment might
be required. If the dynamic string is shorter than the fixed string, the resulting fixed
string will be extended with spaces. If the dynamic string is longer than the fixed
string, the resulting fixed string will be a truncated version of the dynamic string.
No runtime errors are caused by string conversions.
Variant conversions. Siebel VB will automatically convert between any data type and
variants. Basic will convert variant strings to numbers when required. A type
mismatch error will occur if the variant string does not contain a valid
representation of the required number.
No other implicit conversions are supported. In particular, Siebel VB does not
convert automatically between numeric and string data. Use the Val function (see
page 3-362) to convert string to numeric data, and the Str function (see page 3-331)
to convert numeric to string data.
Version 6.0
2-15
Language Overview
Dynamic Arrays
Dynamic Arrays
Dynamic arrays differ from fixed arrays in that a subscript range for the array
elements is not specified when the array is dimensioned. Instead, the subscript
range is set using the ReDim statement (see page 3-263). With dynamic arrays, the
number of array elements can be set based on other conditions in your procedure.
For example, you might want to use an array to store a set of values entered by the
user, but you may not know in advance how many values the user will enter. In this
case, you dimension the array without specifying a subscript range and then
execute a ReDim statement each time the user enters a new value. Or, you might
want to prompt for the number of values to be entered and execute one ReDim
statement to set the size of the array before prompting for the values.
If you use ReDim to change the size of an array and want to preserve the contents
of the array at the same time, be sure to include the Preserve argument to the ReDim
statement:
Redim Preserve ArrayName(n)
The following procedure uses a dynamic array, varray, to hold cash flow values
entered by the user:
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=InputBox("Enter number of cash flow periods")
ReDim varray(cflowper)
For x= 1 to cflowper
varray(x)=InputBox("Enter cash flow amount for period #" _
& x & ":")
Next x
aprate=InputBox("Enter discount rate: ")
If aprate>1 then
aprate=aprate/100
End If
netpv=NPV(aprate,varray())
msgtext="The net present value is: "
msgtext=msgtext & Format(netpv, "Currency")
MsgBox msgtext
End Sub
2-16
Version 6.0
Language Overview
Variant Data Type
If you declare a dynamic array (with a Dim statement) before using it, the maximum
number of dimensions it can have is 8. To create dynamic arrays with more
dimensions (up to 60), do not declare the array at all; instead use just the ReDim
statement inside your procedure.
The variant data type can be used to define variables that contain any type of data.
A tag is stored with the variant data to identify the type of data that it currently
contains. You can examine the tag by using the VarType function.
A variant can contain a value of any of the following types:
Table 2-3.
Type/Name
Size of Data
Range
0 (Empty)
N/A
1 Null
N/A
2 Integer
2 bytes (short)
-32768 to 32767
3 Long
4 bytes (long)
-2.147E9 to 2.147E9
4 Single
4 bytes (float)
5 Double
8 bytes (double)
Version 6.0
6 Currency
8 bytes (fixed)
-9.223E14 to 9.223E14
7 Date
8 bytes (double)
8 String
0 to ~64kbytes
0 to ~64k characters
9 Object
N/A
N/A
2-17
Language Overview
Expressions
Expressions
Numeric Operators
String Operators
Comparison Operators
Logical Operators
2-18
Version 6.0
Language Overview
Expressions
Numeric Operators
Operator
Comments
Exponentiation
-,+
*, /
Mod
-, +
Numeric addition and subtraction. The + operator can also be used for
string concatenation.
String Operators
Operator
Comments
&
String concatenation
String concatenation
Version 6.0
Operator
Comments
>
Greater than
<
Less than
Equal to
<=
>=
<>
Not equal to
2-19
Language Overview
Expressions
For numbers, the operands are widened to the least common type (Integer is
preferred over Long, which is preferred over Single, which is preferred over
Double). For Strings, the comparison is case-sensitive, and based on the collating
sequence used by the language specified by the user using the Windows Control
Panel. The result is 0 for FALSE and -1 for TRUE.
Logical Operators
2-20
Operator
Comments
NOT
AND
OR
XOR
EQV
IMP
Version 6.0
Language Overview
Object Handling
Object Handling
Objects are reusable blocks of code that can be instantiated or referenced to perform
specific tasks. They may be the end products of a software application, such as a
spreadsheet, graph, or document. Each software application has its own set of
properties and methods that change the characteristics of an object.
Properties affect how an object behaves. For example, width is a property of a range
of cells in a spreadsheet, colors are a property of graphs, and margins are a property
of word processing documents.
Methods cause the application to do something to an object. Examples are Calculate
for a spreadsheet, Snap to Grid for a graph, and Auto-Save for a document.
In Siebel VB, you have the ability to access Siebel objects and to change the
properties and methods of that object. This means that, among other things, you
can access an object that is part of the Siebel application by running a VB program
external to Siebel. If you have set up your Visual Basic environment as described in
Setting Up Microsoft Visual Basic to Access the Siebel Applications on page 2-3,
you can simply declare the object as one of the supported Siebel object types.
Before you can use a non-Siebel object in a Siebel VB procedure, however, you must
instantiate the object by assigning it to an object variable. Then you attach an object
name (with or without properties and methods) to the variable to manipulate the
object.
Version 6.0
2-21
Language Overview
Object Handling
On the other hand, when accessing Siebel objects within Siebel VB you can simply
declare an object as one of the supported Siebel object types. The syntax for doing
this is shown in the following example code.
Sub BusComp_NewRecord
Step 1
C re a te a n o b je ct
va ria b le to a cce ss
th e o b je ct.
Step 2
U se m e th o d s a n d
p ro p e rtie s to a ct
o n th e o b je cts.
oBC.ClearToQuery
oBC.ActivateField "Sales Stage Order"
oBC.SetSortSpec "Sales Stage Order"
oBC.ExecuteQuery ForwardOnly
set oBC = Nothing
End Sub
Note that in this example, oBC is not declared as Object, but rather is declared as
BusComp. Here you are instantiating one of the Siebel object types, the Business
Component (BusComp) object type. You could declare it as an object, but if you
want to use the methods associated with the object type, as shown in step 2, you
must declare it as the appropriate object type.
NOTE: You can use a similar procedure to access other types of COM-compliant
objects, using the original software application that created them to change
properties and methods of the objects. You can see an example in the CreateObject
Function on page 3-50.
2-22
Version 6.0
Language Overview
Object Handling
The Dim statement creates an object variable called oBC and assigns a picklist
business component to it. The Set statement assigns the business component to the
variable oBC using a Get method. If you are instantiating an application, you would
use either GetObject or CreateObject. You use GetObject if the application is already
open on the Windows desktop. Use CreateObject if the application is not open.
Version 6.0
2-23
Language Overview
Error Handling
Error Handling
Siebel VB contains three error handling statements and functions for trapping errors
in your program: Err, Error, and On Error. Siebel VB returns a code for many of the
possible runtime errors you might encounter. See Appendix B, Trappable Errors,
for a complete list of codes.
In addition to the errors trapped by Siebel VB, you might want to create your own
set of codes for trapping errors specific to your program. You would do this if, for
example, your program establishes rules for file input and the user does not follow
the rules. You can trigger an error and respond appropriately using the same
statements and functions you would use for error codes returned by Siebel VB.
Regardless of the error trapped, you have one of two methods to handle errors: one
is to put error-handling code directly before a line of code where an error might
occur (such as after a File Open statement), and the other is to label a separate
section of the procedure just for error handling, and force a jump to that label if any
error occurs. The On Error statement handles both options.
For more information, refer to one of the topics below:
Trapping Errors Returned by Siebel VB on page 2-24
Trapping User-Defined (Non-Siebel VB) Errors on page 2-26
This code example shows the two ways to trap errors. Option 1 places errorhandling code directly before the line of code that could cause an error. Option 2
contains a labeled section of code that handles any error.
2-24
Version 6.0
Language Overview
Trapping Errors Returned by Siebel VB
The On Error statement identifies the line of code to go to in case of an error. In this
case, the Resume Next parameter means execution continues with the next line of
code after the error. In this example, the line of code to handle errors is the If
statement. It uses the Err statement to determine which error code is returned.
O ption 1
P la ce e rro rh a n d lin g
co d e w ith in
th e b o d y o f a
p ro ce d u re .
O ption 2
P la ce e rro rh a n d lin g
co d e w ith in
th e b o d y o f a
p ro ce d u re
a n d G o to it
via a la b e l.
Sub Main
Dim UserDrive As String, UserDir As String
Dim msgtext As String
in1:
UserDrive = InputBox("Enter drive: ",,"C:")
On Error Resume Next
Err = 0
ChDrive UserDrive
If Err = 68 Then
MsgBox "Invalid drive. Try again."
Goto in1
End If
On Error Goto Errortrap1
in2:
UserDir = InputBox(Enter directory: ")
ChDir UserDrive & "\" & UserDir
Exit Sub
Errortrap1:
Select Case Err
Case 75
msgtext = "Path is invalid."
Case 76
msgtext = "Path not found."
Case Else
msgtext = "Error " & Err ":" & Error$
End Select
MsgBox msgtext & " Try again."
Resume in2
End Sub
The On Error statement used here specifies a label to jump to in case of errors. The
code segment is part of the main procedure and uses the Err statement to determine
which error code is returned. To make sure your code doesnt accidentally fall
through to the error handler, precede it with an Exit statement.
Version 6.0
2-25
Language Overview
Trapping User-Defined (Non-Siebel VB) Errors
These code examples show the two ways to set and trap user-defined errors. Both
options use the Error statement to set the user-defined error to the value 30000. To
trap the error, option 1 places error-handling code directly before the line of code
that could cause an error. Option 2 contains a labeled section of code that handles
any user-defined errors.
Option 1
P la ce e rro rh a n d lin g co d e
w ith in th e b o d y
o f a p ro ce d u re .
2-26
Sub Main
Dim custname As String
On Error Resume Next
in1:
Err = 0
custname = InputBox("Enter customer name: ")
If custname = "" Then
Error 30000
Select Case Err
Case 30000
MsgBox "You must enter a customer name."
Goto in1
Case Else
MsgBox "Undetermined error. Try again."
End Select
End If
MsgBox "The Name is " & custname & "."
End Sub
Version 6.0
Language Overview
Trapping User-Defined (Non-Siebel VB) Errors
Option 2
P la ce e rro rh a n d lin g co d e
a t th e e n d o f a
p ro ce d u re a n d
G o to it via a
la b e l.
Version 6.0
Sub Main
Dim custname As String
On Error Goto Errortrap1
in1:
Err = 0
custname = InputBox("Enter customer name: ")
If custname = "" Then
Error 30000
End If
MsgBox "The Name is " & custname & "."
Exit Sub
Errortrap1
Select Case Err
Case 30000
MsgBox "You must enter a customer name."
Case Else
MsgBox "Undetermined error. Try again."
End Select
Resume in1
End Sub
2-27
Language Overview
Trapping Errors Generated by Siebel VB Methods
Many Siebel VB methods return error codes; however, they must be handled
differently from those returned by the standard VB functions and statements. Siebel
methods use numeric error codes in the range from 4000 to 4999. For errors
generated by Siebel VB methods documented in the Siebel Object Interfaces
Reference, use a construct of this form to see the text of the error message:
DisplayError:
If ErrCode <> 0 Then
ErrText = GetLastErrText
MsgBox ErrText
Exit Sub
End If
Note that DisplayError: is a label, which will be the target of a Goto statement
elsewhere in the program.
NOTE: The GetLastErrText method is available only via interfaces external to Siebel
Tools. Therefore, you can use it in Microsoft VB, but not in Siebel VB.
2-28
Version 6.0
Version 6.0
3-1
. . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
3-2
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40
Version 6.0
3-3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73
3-4
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-103
Version 6.0
3-5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
3-6
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150
Version 6.0
3-7
3-8
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-229
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-231
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-234
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-235
Version 6.0
3-9
Pmt Function
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-249
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268
3-10
Version 6.0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
Version 6.0
3-11
SetViewMode Method
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-328
3-12
Version 6.0
Version 6.0
3-13
3-14
Version 6.0
This chapter lists the Siebel VB statements and functions in alphabetical order, and
indicates:
Syntax
Return value
Usage
An example
A list of related commands
This chapter also includes information about Siebel VB methods and events. Siebel
VB methods are used to access and affect components of the Siebel software
architecture such as applets and business components. Siebel VB methods must be
prefaced by the name of the architecture component to be addressed; for example:
BusComp.GetFieldValue(fieldName)
Version 6.0
3-15
Abs Function
Syntax
Argument
Description
number
Returns
Usage
The data type of the return value matches the type of the number. If number is a
variant string (vartype 8), the return value will be converted to vartype 5 (double).
If the absolute value evaluates to vartype 0 (Empty), the return value will be
vartype 3 (long).
Example
This example finds the difference between two variables, oldacct and newacct.
Sub Button_Click
Dim oldacct, newacct, count
oldacct = InputBox("Enter the old account number")
newacct = InputBox("Enter the new account number")
count = Abs(oldacct - newacct)
MsgBox "The absolute value is: " & count
End Sub
See Also
3-16
Exp Function on page 3-99, Fix Function on page 3-109, Int Function on page 3-166,
Log Function on page 3-201, Rnd Function on page 3-277, Sgn Function on
page 3-301, and Sqr Function on page 3-327
Version 6.0
ActivateField Method
ActiveApplet Method
ActiveApplet returns name of the applet that has input focus. This method is used
with the application object. For details, see the Siebel Object Interfaces Reference.
ActiveBusComp Method
ActiveBusObject Method
ActiveBusObject returns the business object for a Siebel business component for the
active applet. This method is used with the application object. For details, see the
Siebel Object Interfaces Reference.
ActiveControl Method
ActiveControl returns the Control that currently has the input focus within the
applet. It is used with applet and application objects. For details, see the Siebel
Object Interfaces Reference.
Version 6.0
3-17
ActiveViewName Method
ActiveViewName returns the name of the active view. It is used with applet and
application objects. For details, see the Siebel Object Interfaces Reference.
AddChild Method
The AddChild method is used to add subsidiary property sets to a property set, in
order to form tree-structured data structures. For details, see the Siebel Object
Interfaces Reference.
AllowNotification Method
The AllowNotification method enables updates of the user interface when there are
changes to a Siebel business component. User interface updates are enabled until a
matching call to SuppressNotification. It is used with business component objects.
For details, see the Siebel Object Interfaces Reference.
3-18
Version 6.0
AppActivate Statement
AppActivate title
Argument
Description
title
Returns
Not applicable
Usage
Title must match the name of the window character for character, but comparison
is not case-sensitive; for example, File Manager is the same as file manager
or FILE MANAGER. If there is more than one window with a name matching title,
a window is chosen at random.
AppActivate changes the focus to the specified window but does not change
whether the window is minimized or maximized. Use AppActivate with the
SendKeys statement to send keys to another application.
Example
See Also
Version 6.0
3-19
Applet Method
The Applet Siebel VB method returns the parent applet object for a control on a
Siebel applet. For details, see the Siebel Object Interfaces Reference.
Applet_GotFocus Event
The GotFocus Siebel VB event handler is called when an applet gets the focus. An
applet gets the focus when one of the following occurs: (1) the user navigates to a
view in which the applet is the default applet, (2) the user clicks on a control in the
applet while another applet is active, (3) a pick applet, an MVG applet, a detail
applet, or an association dialog, invoked in the applet, is closed. For details, see the
Siebel Object Interfaces Reference.
Applet_InvokeMethod Event
Applet_Load Event
The Load event is triggered when an applet is loaded. For details, see the Siebel
Object Interfaces Reference.
Applet_LostFocus Event
The LostFocus Siebel VB event handler is called when an applet loses focus. An
applet loses focus when one of the following occurs: (1) the user navigates to
another view, (2) the user clicks on a control in another applet, (3) a pick applet,
an MVG applet, a detail applet, or an association dialog box is displayed, (4) a user
exits the Siebel application. For details, see the Siebel Object Interfaces Reference.
3-20
Version 6.0
Applet_PreInvokeMethod Event
Application_Close Event
The Close Siebel VB event handler is called before exiting the application and after
the PreClose event. This allows Basic scripts to perform last-minute cleanup (such
as cleaning up a connection to a COM server). It is called when the application is
notified by Windows that it should close, but not if the process is terminated
directly. For details, see the Siebel Object Interfaces Reference.
Application_InvokeMethod Event
Application_PreClose Event
The PreClose Siebel VB event handler is called before the Close event when the user
exits the application. For details, see the Siebel Object Interfaces Reference.
Application_PreInvokeMethod Event
Application_Start Event
The Start Siebel VB event handler is called when the client starts and the user
interface is first displayed. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-21
Asc Function
This standard VB function returns an integer corresponding to the ANSI code of the
first character in the specified string.
Asc(string)
Syntax
Argument
Description
string
Returns
An integer corresponding to the ANSI code of the first character in the argument.
Usage
Example
This example asks the user for a letter and returns its ANSI value.
Sub Button_Click
Dim userchar As String
userchar = InputBox("Type a letter:")
MsgBox "The ASC value for " & userchar & " is: " & Asc(userchar)
End Sub
See Also
Associate Method
The Associate method creates a new many-to-many relationship for the parent
object through an association business component. It is used with business
components. For details, see the Siebel Object Interfaces Reference.
3-22
Version 6.0
Atn Function
This standard VB function returns the angle (in radians) for the arctangent of the
specified number.
Syntax
Atn(number)
Argument
Description
number
Returns
Usage
The Atn function assumes number is the ratio of two sides of a right triangle: the
side opposite the angle to find and the side adjacent to the angle. The function
returns a single-precision value for a ratio expressed as an integer, a currency, or a
single-precision numeric expression. The return value is a double-precision value
for a long, variant, or double-precision numeric expression.
To convert radians to degrees, multiply by (180/PI). The value of PI is
approximately 3.14159.
Example
This example finds the roof angle necessary for a house with an attic ceiling of 8
feet (at the roof peak) and a 16 foot span from the outside wall to the center of the
house. The Atn function returns the angle in radians; it is multiplied by 180/PI to
convert it to degrees.
Sub Button_Click
Dim height As Single, span As Single, angle As Single
Dim PI As Single
PI = 3.14159
height = 8
span = 16
angle = Atn(height/span) * (180/PI)
MsgBox "The angle is " & Format(angle, "##.##") & " degrees"
End Sub
See Also
Version 6.0
Cos Function on page 3-49, Sin Function on page 3-304, Tan Function on
page 3-341, and Appendix C, Derived Trigonometric Functions
3-23
Beep Statement
Syntax
Argument
Description
Not applicable
Returns
Not applicable
Usage
The sound emitted when the Beep statement is executed is the Default Beep
configured in the Windows Control Panel. The Beep statement is most often used
to accompany a message or signal the completion of a process.
Example
3-24
Version 6.0
BusComp Method
BusComp_Associate Event
The Associate Siebel VB event handler is called after a record is added to a business
component to create an association. For details, see the Siebel Object Interfaces
Reference.
BusComp_ChangeRecord Event
The ChangeRecord Siebel VB event handler is called after a record becomes the
current row in a Siebel business component. For details, see the Siebel Object
Interfaces Reference.
BusComp_CopyRecord Event
The CopyRecord Siebel VB event handler is called after a row has been copied in a
Siebel business component and that row has been made active. For details, see the
Siebel Object Interfaces Reference.
BusComp_DeleteRecord Event
The DeleteRecord Siebel VB event handler is called after a row in a Siebel business
component is deleted. The current context is a different row (the Fields of the justdeleted row are no longer available). For details, see the Siebel Object Interfaces
Reference.
Version 6.0
3-25
BusComp_InvokeMethod Event
BusComp_NewRecord Event
The NewRecord Siebel VB event handler is called after a new row has been created
in a Siebel business component and that row has been made active. The event may
be used to set up default values for Fields. For details, see the Siebel Object Interfaces
Reference.
BusComp_PreAssociate Event
BusComp_PreCopyRecord Event
The PreCopyRecord Siebel VB event handler is called before a new row is copied in
a Siebel business component. The event may be used to perform precopy validation.
For details, see the Siebel Object Interfaces Reference.
BusComp_PreDeleteRecord Event
3-26
Version 6.0
BusComp_PreGetFieldValue Event
The PreGetFieldValue Siebel VB event handler is called when the value of a business
component field is accessed. For details, see the Siebel Object Interfaces Reference.
BusComp_PreInvokeMethod Event
BusComp_PreNewRecord Event
The PreNewRecord Siebel VB event handler is called before a new row is created in
a Siebel business component. The event may be used to perform preinsert
validation. For details, see the Siebel Object Interfaces Reference.
BusComp_PreQuery Event
The PreQuery Siebel VB event handler is called before query execution. For details,
see the Siebel Object Interfaces Reference.
BusComp_PreSetFieldValue Event
Version 6.0
3-27
BusComp_PreWriteRecord Event
The PreWriteRecord Siebel VB event handler is called before a row is written out to
the database. The event may perform any final validation necessary before the
actual save occurs. For details, see the Siebel Object Interfaces Reference.
BusComp_Query Event
The Query Siebel VB event handler is called just after the query is complete and all
the rows have been retrieved, but before the rows are actually displayed. For details,
see the Siebel Object Interfaces Reference.
BusComp_SetFieldValue Event
The SetFieldValue Siebel VB event handler is called when a value is pushed down
into a Siebel business component from the user interface or through a call to
SetFieldValue. For details, see the Siebel Object Interfaces Reference.
BusComp_WriteRecord Event
The WriteRecord Siebel VB event handler is called after a row is written out to the
database. For details, see the Siebel Object Interfaces Reference.
BusObject Method
BusObject returns the business object for the specified object. It is used with applet,
service, control, and web applet objects. For details, see the Siebel Object Interfaces
Reference.
3-28
Version 6.0
Call Statement
Syntax B
subprogram_name argument_list
subprogram_name is the name of the subprogram or function to which control is to
be passed.
Argument
Description
argument_list
Returns
Usage
Use the Call statement to call a subprogram or function written in Basic or to call C
procedures in a DLL. These C procedures must be described in a Declare statement
or be implicit in the application.
If a procedure accepts named arguments, you can use the names to specify the
argument and its value. Order is not important. For example, if a procedure is
defined as follows:
Sub mysub(aa, bb, optional cc, optional dd)
2)
where argname is the name for the argument as supplied in the Sub or Function
statement and argvalue is the value to assign to the argument when you call it.
Version 6.0
3-29
The advantage to using named arguments is that you do not have to remember the
order specified in the procedures original definition, and if the procedure takes
optional arguments, you do not need to include commas (,) for arguments that you
leave out.
The procedures that can use named arguments include:
3-30
Version 6.0
Example
This example calls a subprogram named CreateFile to open a file, write the
numbers 1 to 10 in it, and leave it open. The calling procedure then checks the files
mode. If the mode is 1 (open for Input) or 2 (open for Output), the procedure closes
the file.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
End Sub
Sub Button1_Click
Dim filemode as Integer
Dim attrib as Integer
Call CreateFile
attrib = 1
filemode = FileAttr(1,attrib)
If filemode = 1 or filemode = 2 then
MsgBox "File was left open. Closing now."
Close #1
End If
Kill "c:\temp001"
End Sub
See Also
Version 6.0
3-31
CCur Function
Syntax
Argument
Description
expression
Returns
Usage
CCur accepts any type of expression. Numbers that do not fit in the currency data
type result in an Overflow error. Strings that cannot be converted result in a Type
Mismatch error. Variants containing null result in an Illegal Use of Null error.
3-32
Version 6.0
Example
This example converts a yearly payment on a loan to a currency value with four
decimal places. A subsequent Format statement formats the value to two decimal
places before displaying it in a message box.
Sub Button_Click
Dim aprate, totalpay, loanpv
Dim loanfv, due, monthlypay
Dim yearlypay, msgtext
loanpv = InputBox("Enter the loan amount:")
aprate = InputBox("Enter the annual percentage rate:")
If aprate >1 then
aprate = aprate/100
End If
aprate = aprate/12
totalpay = InputBox("Enter the total number of pay periods:")
loanfv = 0
Rem Assume payments are made at end of month
due = 0
monthlypay = Pmt(aprate,totalpay,-loanpv,loanfv,due)
yearlypay = CCur(monthlypay * 12)
msgtext = "The yearly payment is: " & _
Format(yearlypay, "Currency")
MsgBox msgtext
End Sub
See Also
Version 6.0
CDbl Function on page 3-34, Chr Function on page 3-38, CInt Function on
page 3-40, CLng Function on page 3-44, CSng Function on page 3-52, CStr Function
on page 3-54, CVar Function on page 3-58, and CVDate Function on page 3-59
3-33
CDbl Function
Syntax
Argument
Description
expression
Returns
Usage
CDbl accepts any type of expression. Strings that cannot be converted to a doubleprecision floating point result in a Type Mismatch error. Variants containing null
result in an Illegal Use of Null error.
Example
See Also
3-34
CCur Function, CInt Function on page 3-40, CLng Function on page 3-44, CSng
Function on page 3-52,CStr Function on page 3-54, CVar Function on page 3-58,
and CVDate Function on page 3-59
Version 6.0
ChDir Statement
This standard VB statement changes the default directory for the specified drive.
Syntax
ChDir [drive][[\]directory\]directory
Argument
Description
drive
The name of the drive containing the desired default directory as a letter,
or a string expression representing the drive name; a colon is not required
[\]directory\
If the directory is not within the current directory of the specified drive
(or the default drive if none is specified), the path to the directory to
become the default, or a string expression representing the path
directory
Returns
Not applicable
Usage
If the drive argument is omitted, ChDir changes the default directory on the current
drive. If the initial backslash in [\]directory\ is omitted, ChDir changes to a
subdirectory of the current directory. If it is included, the path is followed from the
root directory.
The ChDir statement does not change the default drive. To change the default drive,
use ChDrive.
Example
This example changes the current directory to C:\Windows, if it is not already the
default.
Sub Button_Click
Dim newdir as String
newdir = "c:\Windows"
If CurDir <> newdir then
ChDir newdir
End If
MsgBox "The default directory is now: " & newdir
End Sub
Version 6.0
3-35
See Also
3-36
ChDrive Statement on page 3-37, CurDir Function on page 3-56, Dir Function on
page 3-79, MkDir Statement on page 3-213, and RmDir Statement on page 3-275
Version 6.0
ChDrive Statement
ChDrive drive
Argument
Description
drive
Returns
Not applicable
Usage
A colon is permitted but not required as part of the name of the drive; a single letter
suffices. The drive to be made the default must exist and must be within the range
specified by the LASTDRIVE statement in the config.sys file. If a null string ("") is
supplied as the argument, the default drive remains the same. If the drive argument
is a string, ChDrive uses the first letter only. If the argument is omitted, an error
message is displayed. To change the current directory on a drive, use ChDir.
Example
See Also
Version 6.0
ChDir Statement on page 3-35, CurDir Function on page 3-56, Dir Function on
page 3-79, MkDir Statement on page 3-213, and RmDir Statement on page 3-275
3-37
Chr Function
Syntax
Argument
Description
charCode
An integer between 0 and 255 representing the ANSI code for a character
Returns
Usage
The dollar sign ($) in the function name is optional. If it is included, the return type
is string, otherwise the function returns a variant of vartype 8 (string).
Example
This example displays the character equivalent for an ASCII code between 65 and
122 typed by the user.
Sub Button_Click
Dim numb as Integer
Dim msgtext as String
Dim out as Integer
out = 0
Do Until out
numb = InputBox("Type a number between 65 and 122:")
If Chr$(numb)> = "A" AND Chr$(numb)< = "Z" _
OR Chr$(numb)> = "a" AND Chr$(numb)< = "z" then
msgtext = "The letter for the number " & numb _
&" is: " & Chr$(numb)
out = 1
ElseIf numb = 0 then
Exit Sub
Else
Beep
msgtext = "Does not convert to a character; try again."
End If
MsgBox msgtext
Loop
End Sub
3-38
Version 6.0
See Also
Version 6.0
Asc Function on page 3-22, CCur Function on page 3-32, CDbl Function on
page 3-34, CInt Function on page 3-40, CLng Function on page 3-44, CSng Function
on page 3-52, CStr Function on page 3-54, CVar Function on page 3-58, CVDate
Function on page 3-59, Format Function on page 3-114, and Val Function on
page 3-362
3-39
CInt Function
Syntax
Argument
Description
expression
Returns
Usage
After rounding, the resulting number must be within the range of -32767 to 32767,
or an error occurs.
Strings that cannot be converted to an integer result in a Type Mismatch error.
Variants containing null result in an Illegal Use of Null error.
Example
See Also
3-40
CCur Function on page 3-32, CDbl Function on page 3-34, CLng Function on
page 3-44, CSng Function on page 3-52,CStr Function on page 3-54, CVar Function
on page 3-58, CVDate Function on page 3-59
Version 6.0
ClearToQuery Method
The ClearToQuery method clears the current query and sort specifications on a
Siebel business component. It is used with business component objects. For details,
see the Siebel Object Interfaces Reference.
Version 6.0
3-41
Clipboard
The Clipboard methods are standard VB methods that allow you to access the
Windows Clipboard as an object.
Clipboard.Clear
Clipboard.GetText()
Clipboard.SetText string
Clipboard.GetFormat()
Syntax
Argument
Description
string
Returns
Not applicable
Usage
The Windows Clipboard can be accessed directly by your program to enable you to
transfer text to and from other applications that support the Clipboard. The
supported Clipboard methods are as follows:
Method:
What it does:
Clear
GetText
SetText
GetFormat
Returns TRUE (non-0) if the format of the item on the Clipboard is text.
Otherwise, returns FALSE (0)
NOTE: Data on the Clipboard is lost when another set of data of the same format is
placed on the Clipboard (either through code or through a cut or copy operation in
an application).
3-42
Version 6.0
Example
This example places the text string Hello, world. on the Clipboard.
Sub Button_Click
Dim mytext as String
mytext = "Hello, world."
Clipboard.Settext mytext
MsgBox "The text: '" & mytext & "' added to the Clipboard."
End Sub
Version 6.0
3-43
CLng Function
This standard VB function converts an expression to the data type long by rounding.
CLng(expression)
Syntax
Argument
Description
expression
Returns
Usage
After rounding, the resulting number must be within the range of -2,147,483,648 to
2,147,483,647, or an error occurs.
Strings that cannot be converted to a long result in a Type Mismatch error.
Variants containing null result in an Illegal Use of Null error.
Example
This example divides the US national debt by the number of people in the country
to find the amount of money each person would have to pay to wipe it out. This
figure is converted to a long integer and formatted as currency.
Sub Button_Click
Dim debt As Single
Dim msgtext
Const Populace = 250000000
debt = InputBox("Enter the current US national debt:")
msgtext = "The $/citizen is: " & _
Format(CLng(Debt/ Populace), "Currency")
MsgBox msgtext
End Sub
See Also
3-44
CCur Function on page 3-32, CDbl Function on page 3-34, CInt Function on
page 3-40, CSng Function on page 3-52,CStr Function on page 3-54, CVar Function
on page 3-58, and CVDate Function on page 3-59
Version 6.0
Close Statement
Description
filenumber
The file number used in the Open statement to open the file, identifying
the file to close
Returns
Not applicable
Usage
Filenumber is the number assigned to the file in the Open statement and can be
preceded by a pound sign (#). If this argument is omitted, all open files are closed.
Once a Close statement is executed, the association of a file with filenumber is
ended, and the file can be reopened with the same or a different file number.
When the Close statement is used, the final output buffer is written to the operating
system buffer for that file. Close frees all buffer space associated with the closed file.
Use the Reset statement so that the operating system will flush its buffers to disk.
Example
This example opens a file for random access, gets the contents of one variable, and
closes the file again. The subprogram, CreateFile, creates the file c:\temp001
used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
Reset
End Sub
Version 6.0
3-45
Sub Button1_Click
Dim acctno as String * 3
Dim recno as Long
Dim msgtext as String
Call CreateFile
recno = 1
newline = Chr(10)
Open "c:\temp001" For Random As #1 Len = 3
msgtext = "The account numbers are:" & newline & newline
Do Until recno = 11
Get #1,recno,acctno
msgtext = msgtext & acctno
recno = recno + 1
Loop
MsgBox msgtext
Close #1
Reset
Kill "c:\temp001"
End Sub
See Also
3-46
Open Statement on page 3-238, Reset Statement on page 3-269, and Stop Statement
on page 3-330
Version 6.0
Const Statement
This standard VB statement declares symbolic constants for use in a Basic program.
Syntax
Description
constantName
type
expression
Returns
Not applicable
Usage
Instead of using the As clause, the type of the constant can be specified by using a
type character as a suffix (# for numbers, $ for strings) to the constantName. If no
type character is specified, the type of the constantName is derived from the type
of the expression.
To specify a Global Const, you must follow the same rules for declaring a Global
variable: It must be declared in the (general) (declarations) section of all modules
in which you wish to access the Global variable.
Example
See Also
Declare Statement on page 3-68, Deftype Statement on page 3-71, Dim Statement on
page 3-73, Let (Assignment Statement) on page 3-191, and Type Statement on
page 3-354
Version 6.0
3-47
Copy Method
Copy returns a copy of a property set. For details, see the Siebel Object Interfaces
Reference.
3-48
Version 6.0
Cos Function
Cos(number)
Argument
Description
number
An angle in radians
Returns
Usage
The return value will be between -1 and 1. The return value is a single-precision
number if the angle has a data type integer or currency, or is a single-precision
value. The return value will be a double precision value if the angle has a data type
long or variant, or is a double-precision value.
The angle can be either positive or negative. To convert degrees to radians, multiply
by (PI/180). The value of PI is approximately 3.14159.
Example
This example finds the length of a roof, given its pitch and the distance of the house
from its center to the outside wall.
Sub Button_Click
Dim bwidth As Single, roof As Single, pitch As Single
Dim msgtext
Const PI = 3.14159
Const conversion = PI/180
pitch = InputBox("Enter roof pitch in degrees")
pitch = Cos(pitch * conversion)
bwidth = InputBox("Enter 1/2 of house width in feet")
roof = bwidth/pitch
msgtext = "The length of the roof is " & _
Format(roof, "##.##") & " feet."
MsgBox msgtext
End Sub
See Also
Version 6.0
Atn Function on page 3-23, Sin Function on page 3-304, Tan Function on
page 3-341, and Appendix C, Derived Trigonometric Functions
3-49
CreateObject Function
Syntax
Argument
Description
application
objectname
Returns
Not applicable
Usage
To create an object, you first must declare an object variable, using Dim, and then
Set the variable equal to the new object, as follows:
Dim Application As Object
Set Application = CreateObject _
("SiebelDataServer.ApplicationObject")
To refer to a method or property of the newly created object, use the syntax
objectvar.property or objectvar.method, as follows:
Dim sPosId As String
sPosId = Application.PositionId
Refer to the documentation provided with your COM automation server application
for correct application and object names.
Example
This example uses CreateObject to create an Excel worksheet, then edits and saves
the worksheet.
Sub BtnExcel_Click
Dim oWorkSheet As Object
Dim sfileName As String
Set oWorkSheet = CreateObject("Excel.Sheet")
If oWorkSheet Is Nothing then
MsgBox "Couldnt open Excel!"
Exit Sub
End If
3-50
Version 6.0
This example uses CreateObject to create a Word document, then edits and saves
the document.
Sub BtnWrd_Click
Dim oWord As Object
Dim fileName As String
fileName = "C:\demo.doc"
Set oWord = CreateObject("Word.Application")
' Create a new document
oWord.Documents.Add
If oWord Is Nothing then
MsgBox "Couldnt open Word!"
Exit Sub
End If
' Make Word visible through the Application object
Word.Application.Visible = 1
' Add some text
oWord.Selection.TypeText "This is a demo."
' Save the document
oWord.ActiveDocument.SaveAs (fileName)
' Close Word with the Quit method on the Application object
oWord.Quit
' Clear the object from memory
Set oWord = Nothing
End Sub
See Also
Version 6.0
3-51
CSng Function
Syntax
Argument
Description
expression
Returns
Usage
The expression must have a value within the range allowed for the single data type,
or an error occurs.
Strings that cannot be converted to an integer result in a Type Mismatch error.
Variants containing null result in an Illegal Use of Null error.
Example
3-52
Version 6.0
factorial = 1
For x = number to 2 step -1
factorial = factorial * x
Next x
'If number <= 35, then its factorial is small enough to
' be stored as a single-precision number
If number< 35 then
factorial = CSng(factorial)
End If
msgtext = "The factorial of " & number & " is " & factorial
MsgBox msgtext
End Sub
See Also
Version 6.0
CCur Function on page 3-32, CDbl Function on page 3-34, CInt Function on
page 3-40, CLng Function on page 3-44, CStr Function on page 3-54, CVar Function
on page 3-58, and CVDate Function on page 3-59
3-53
CStr Function
Syntax
Returns
Example
Argument
Description
expression
CStr returns:
Date
Empty
Error
Null
A run-time error
Other Numeric
This example uses the string functions to operate on a string that was originally
entered as a number.
Sub Button_Click
Dim var1, msgtext as String, code as Integer
var1 = InputBox("Enter a number:")
msgtext = Cstr(var1)
msgtext = Left(var1,1)
code = Asc(msgtext)
msgtext = "The first digit you entered was," & msgtext
msgtext = msgtext & ". Its ANSI code is " & code & "."
MsgBox msgtext
End Sub
3-54
Version 6.0
See Also
Version 6.0
Asc Function on page 3-22, CCur Function on page 3-32, CDbl Function on
page 3-34, Chr Function on page 3-38, CInt Function on page 3-40, CLng Function
on page 3-44, CSng Function on page 3-52, CVar Function on page 3-58, CVDate
Function on page 3-59, and Format Function on page 3-114
3-55
CurDir Function
This standard VB function returns the default directory (and drive) for the specified
drive.
CurDir[$][(drive)]
Syntax
Argument
Description
drive
Returns
Usage
A colon is not required after the drive name. The drive must exist, and must be
within the range specified in the LASTDRIVE statement of the config.sys file. If a
null argument ("") is supplied, or if no drive is indicated, the path for the default
drive is returned.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
To change the current drive, use ChDrive. To change the current directory, use
ChDir.
Example
This example changes the current directory to C:\Windows, if it is not already the
default.
Sub Button_Click
Dim newdir as String
newdir = "c:\Windows"
If CurDir <> newdir then
ChDir newdir
End If
MsgBox "The default directory is now: " & newdir
End Sub
See Also
3-56
ChDir Statement on page 3-35, ChDrive Statement on page 3-37, Dir Function on
page 3-79, MkDir Statement on page 3-213, and RmDir Statement on page 3-275
Version 6.0
CurrencyCode Method
CurrencyCode returns the operating currency code associated with the division to
which the users position has been assigned. It is used with the application object.
For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-57
CVar Function
Syntax
Argument
Description
expression
Returns
Usage
Example
See Also
3-58
CCur Function on page 3-32, CDbl Function on page 3-34, CInt Function on
page 3-40, CLng Function on page 3-44, CSng Function on page 3-52, CStr Function
on page 3-54, CVar Function on page 3-58, and CVDate Function on page 3-59
Version 6.0
CVDate Function
This standard VB function converts an expression to the data type variant of type
date.
Syntax
CVDate(expression)
Argument
Description
expression
Returns
Usage
Version 6.0
3-59
Example
This example displays the date for one week from the date entered by the user.
Sub Button_Click
Dim str1 as String
Dim nextweek
Dim msgtext as String
i:
str1 = InputBox$("Enter a date:")
answer = IsDate(str1)
If answer = -1 then
str1 = CVDate(str1)
nextweek = DateValue(str1) + 7
msgtext = "One week from the date entered is:
msgtext = msgtext & "Format(nextweek,"dddddd")
MsgBox msgtext
Else
MsgBox "Invalid date or format. Try again."
Goto i
End If
End Sub
See Also
3-60
Version 6.0
Date Function
Date[$]
Argument
Description
Not applicable
Returns
Usage
Example
This example displays the date for one week from todays date (the current date on
the computer).
Sub Button_Click
Dim nextweek
nextweek = CVar(Date) + 7
MsgBox "One week from today is: " & Format _
(nextweek,"ddddd")
End Sub
See Also
Version 6.0
CVDate Function on page 3-59, Date Statement on page 3-62, DateSerial Function
on page 3-64, Format Function on page 3-114, Now Function on page 3-226, Time
Function on page 3-343, Time Statement on page 3-345, Timer Function on
page 3-347, and TimeSerial Function on page 3-349
3-61
Date Statement
Syntax
Argument
Description
expression
mm-dd-yy
mm-dd-yyyy
mm/dd/yy
mm/dd/yyyy
Meaning
mm
dd
yy
yyyy
Returns
Not applicable
Usage
If the dollar sign ($) is omitted, expression can be a string containing a valid date,
a variant of vartype 7 (date), or a variant of vartype 8 (string).
If expression is not already a variant of vartype 7 (date), Date attempts to convert it
to a valid date from January 1, 1980 through December 31, 2099. Date uses the
Short Date format in the International section of Windows Control Panel to
recognize day, month, and year if a string contains three numbers delimited by valid
date separators. In addition, Date recognizes month names in either full or
abbreviated form.
3-62
Version 6.0
Example
This example changes the system date to a date entered by the user.
Sub Button_Click
Dim userdate
Dim answer
i:
userdate = InputBox("Enter a date for the system clock:")
If userdate = "" then
Exit Sub
End If
answer = IsDate(userdate)
If answer = -1 then
Date = userdate
Else
MsgBox "Invalid date or format. Try again."
Goto i
End If
End Sub
See Also
Version 6.0
Date Function on page 3-61, Time Function on page 3-343, and Time Statement on
page 3-345
3-63
DateSerial Function
This standard VB function returns a date value for year, month, and day specified.
DateSerial(year, month, day)
Syntax
Argument
Description
year
month
day
Returns
A variant of vartype 7 (date) that represents a date from January 1, 100 through
December 31, 9999, where January 1, 1900 is 2.
Usage
A numeric expression can be used for any of the arguments to specify a relative
date: a number of days, months, or years before or after a certain date.
Example
This example finds the day of the week New Years day will be for the year 2001.
Sub Button_Click
Dim newyearsday As Variant, daynumber As Variant
Dim msgtext As String, newday as Variant
Const newyear = 2001
Const newmonth = 1
newday = 1
newyearsday = DateSerial(newyear,newmonth,newday)
daynumber = Weekday(newyearsday)
msgtext = "New Year's day 2001 falls on a " & _
Format(daynumber, "dddd")
MsgBox msgtext
End Sub
See Also
3-64
DateValue Function on page 3-65, Day Function on page 3-67, Format Function on
page 3-114, Month Function on page 3-214, Now Function on page 3-226,
TimeSerial Function on page 3-349, TimeValue Function on page 3-350,
WebApplet_InvokeMethod Event on page 3-366, and Year Function on page 3-376
Version 6.0
DateValue Function
This standard VB function returns a date value for the string specified.
Syntax
DateValue(date)
Argument
Description
date
Returns
A variant of vartype 7 (date) that represents a date from January 1, 100 through
December 31, 9999, where January 1, 1900 is 2.
Usage
DateValue accepts several different string representations for a date. It makes use of
the operating systems international settings for resolving purely numeric dates. In
contrast to the CVDate function (see page 3-59), the argument to the DateValue
function must be in a valid date format. If given a time in acceptable format,
DateValue changes the time to 12:00:00 AM regardless of the value given. If given
a number that is not an acceptable date or time format, DateValue returns a Type
Mismatch error. See the Format Function on page 3-114 for ways to display the
desired result of a date conversion.
Example
This example displays the date for one week from the date entered by the user.
Sub Button_Click
Dim str1 As String, answer As Integer, msgtext As String
Dim nextweek
i:
str1 = InputBox$("Enter a date:")
answer = IsDate(str1)
If answer = -1 then
str1 = CVDate(str1)
nextweek = DateValue(str1) + 7
msgtext = "One week from your date is: "
msgtext = msgtxt & Format(nextweek,"dddddd")
MsgBox msgtext
Else
msgtext = "Invalid date or format. Try again."
MsgBox msgtext
Goto i
End If
End Sub
Version 6.0
3-65
See Also
3-66
DateSerial Function on page 3-64, Day Function on page 3-67, Format Function on
page 3-114, Month Function on page 3-214, Now Function on page 3-226,
TimeSerial Function on page 3-349, TimeValue Function on page 3-350,
WebApplet_InvokeMethod Event on page 3-366, and Year Function on page 3-376
Version 6.0
Day Function
This standard VB function returns the day of the month of a date-time value.
Syntax
Day(date)
Argument
Description
date
Usage
Day attempts to convert the input value of date to a date value. The return value is
a variant of vartype 2 (integer). If the value of date is null, a variant of vartype 1
(null) is returned.
Example
This example finds the month (1-12) and day (1-31) values for this Thursday.
Sub Button_Click
Dim x As Integer, Today As Variant, msgtext As String
Today = DateValue(Now)
Let x = 0
Do While Weekday(Today + x) <> 5
x = x + 1
Loop
msgtext = "This Thursday is: " & Month(Today + x) & "/" & _
Day(Today + x)
MsgBox msgtext
End Sub
See Also
Date Function on page 3-61, Date Statement on page 3-62, Hour Function on
page 3-152, Minute Function on page 3-211, Month Function on page 3-214, Now
Function on page 3-226, Second Function on page 3-282,
WebApplet_InvokeMethod Event on page 3-366, and Year Function on page 3-376
DeactivateFields Method
DeactivateFields deactivates all of the Fields which are currently active from a
business component SQL query statement. It is used with business component
objects. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-67
Declare Statement
Syntax B
Returns
Argument
Description
name
parameter
type
funcType
Usage
To specify the data type for the return value of a function, end the function name
with a type character or use the As funcType clause shown above. If no type is
provided, the function defaults to data type variant.
Siebel Tools compiles custom functions in alphabetical order. Therefore, when a
procedure in the current module is referenced before it is defined, a declaration
must be used. In this case, the Lib and Alias clauses are not used.
3-68
Version 6.0
For example, suppose you have created the following subroutines in the (general)
(declarations) section of a module:
Sub A
theApplication.msgbox "Calling B"
B
End Sub
Sub B
theApplication.msgbox "Sub B called"
End Sub
Compilation will fail, with the message, Unknown function: B. However, placing
the statement
Declare Sub B
Version 6.0
3-69
Any can be used as a type specification, and permits a call to the procedure to pass
a value of any datatype. When Any is used, type checking on the actual argument
used in calls to the procedure is disabled (although other arguments not declared
as type Any are fully type-safe). The actual argument is passed by Far reference,
unless ByVal is specified, in which case the actual value is placed on the stack (or
a pointer to the string in the case of string data). ByVal can also be used in the call.
It is the external DLL procedures responsibility to determine the type and size of
the passed-in value.
When an empty string ("") is passed ByVal to an external procedure, the external
procedure will receive a valid (non-NULL) pointer to a character of 0. To send a
NULL pointer, Declare the procedure argument as ByVal As Any, and call the
procedure with an argument of 0.
Example
This example declares a function that is later called by the main subprogram. The
function does nothing but set its return value to 1. For other examples of functions,
see Function...End Function Statement on page 3-127 and GoTo Statement on
page 3-148.
(general) (declarations)
Option Explicit
Declare Function SVB_exfunction()
Function SVB_exfunction()
SVB_exfunction = 1
End Function
Sub Button_Click
Dim y as Integer
Call SVB_exfunction
y = SVB_exfunction
MsgBox "The value returned by the function is: " & y
End Sub
See Also
3-70
Const Statement on page 3-47, Deftype Statement on page 3-71, Dim Statement on
page 3-73, Static Statement on page 3-328, and Type Statement on page 3-354
Version 6.0
Deftype Statement
This standard VB statement specifies the default data type for one or more
variables.
Syntax
DefCur varTypeLetters
DefInt varTypeLetters
DefLng varTypeLetters
DefSng varTypeLetters
DefDbl varTypeLetters
DefStr varTypeLetters
DefVar varTypeLetters
Argument
Description
varTypeLetter
Returns
Not applicable
Usage
Version 6.0
3-71
Example
This example finds the average of bowling scores entered by the user. Since the
variable average begins with A, it is automatically defined as a single-precision
floating point number. The other variables will be defined as integers.
DefInt c,s,t
DefSng a
Sub Button_Click
Dim count
Dim total
Dim score
Dim average
Dim msgtext
For count = 0 to 4
score = InputBox("Enter bowling score #" & count + 1 &":")
total = total + score
Next count
average = total/count
msgtext = "Your average is: " &average
MsgBox msgtext
End Sub
See Also
Declare Statement on page 3-68, Dim Statement on page 3-73, Global Statement on
page 3-144, Let (Assignment Statement) on page 3-191, and Type Statement on
page 3-354
DeleteRecord Method
3-72
Version 6.0
Dim Statement
Dim [Shared] variableName [As[ New] type] [, variableName [As[ New] type]] ...
Placeholder
Description
variableName
type
Returns
Not applicable
Usage
If the As clause is not used, the type of the 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 Dim statement (although not on the same variable).
Basic is a strongly typed language: all variables must be given a data type or they
will be automatically assigned the data type variant. The available data types are:
Array
Double (double-precision floating-point number)
Integer
Long (double-precision integer)
Object
Version 6.0
3-73
Record
Single (single-precision floating-point number)
String
Variant
For details on these variable types, see Data Types on page 2-11.
Variables can be shared across modules. A variable declared inside a procedure has
scope local to that procedure. A variable declared outside a procedure has scope
local to the module. If you declare a variable with the same name as a module
variable, the module variable is not accessible. See the Global Statement on
page 3-144 for details.
The Shared keyword is included for backward compatibility with older versions of
Basic. It is not allowed in Dim statements inside a procedure. It has no effect.
Regardless of which mechanism you use to declare a 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.
NOTE: It is considered good programming practice to declare all variables. To force
all variables to be explicitly declared use the Option Explicit statement (see
page 3-246). It is also recommended that you place all procedure-level Dim
statements at the beginning of the procedure.
3-74
Version 6.0
Arrays
The available data types for arrays are: numbers, strings, variants, objects 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:
Dim variable([[startSubcript To] endSubscript, ...]) As typeName
or
Dim variable_with_suffix([[startSubcript To] endSubscript, ... ])
Argument
Description
endSubscript
startSubscript
[Optional] the index number of the first array element, followed by the
keyword To
If startSubscript is not specified, 0 is used as the default. The Option Base statement
can be used to change the default.
Version 6.0
3-75
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.
The maximum total size for an array is limited only by the amount of memory
available.
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.
Numbers
Numeric variables can be declared using the As clause and one of the following
numeric types: currency, integer, long, single, double. Numeric variables can also
be declared by including a type character as a suffix to the name. Numeric variables
are initialized to 0.
Objects
Object variables are declared using an As clause and a typeName of a class. Object
variables can be set to refer to an object, and then used to access members and
methods of the object using dot notation.
Dim COMObject As Object
Set COMObject = CreateObject("spoly.cpoly")
COMObject.reset
In such instances, a Set statement is not required to create the object variable; a new
object will be allocated when the variable is used.
NOTE: The New operator cannot be used with the Basic Object class.
Records
Record variables are declared by using an As clause and a typeName that has been
defined previously using the Type statement. The syntax to use is:
Dim variableName As typeName
3-76
Version 6.0
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. See the Type
Statement on page 3-354 for details on accessing fields within a record.
Strings
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:
Dim variableName As String * length
Dynamic strings have no declared length, and can vary in length from 0 to 32,767.
The initial length for a dynamic string is 0. Use the following syntax to declare a
dynamic string:
Dim variableName$
or
Dim variableName As String
When initialized, fixed-length strings are filled with zeros. Dynamic strings are
initialized as zero-length strings.
Variants
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:
Dim variableName
or
Dim variableName As Variant
Version 6.0
3-77
Example
This example shows a Dim statement for each of the possible data types.
' Must define a record type before you can declare a record
' variable
Type Testrecord
Custno As Integer
Custname As String
End Type
Sub Button_Click
Dim counter As Integer
Dim fixedstring As String * 25
Dim varstring As String
Dim myrecord As Testrecord
Dim ole2var As Object
Dim F(1 to 10), A()
'...(code here)...
End Sub
See Also
3-78
Global Statement on page 3-144, Option Base Statement on page 3-241 ReDim
Statement on page 3-263, Service_InvokeMethod Event on page 3-294, Static
Statement on page 3-328, and Type Statement on page 3-354
Version 6.0
Dir Function
The standard VB function Dir returns a filename that matches the specified pattern,
having the specified attributes.
Syntax
Returns
Description
pathname
attributes
The first filename that matches the pathname argument and has the specified
attributes. Use the following integer values for attributes to return the specified type
of file.
Integer
File Type
0 (default)
16
NOTE: The values in the table can be added together to select multiple attributes. For
example, to list hidden and system files in addition to normal files set attributes to
6 (6 = 2 + 4). If attributes is set to 8, the Dir function returns the volume label of
the drive specified in the pathname argument, or of the current drive if a drive is
not explicitly specified.
Version 6.0
3-79
Pathname can include a drive specification and wildcard characters (? and *). An
empty string ("") passed as pathname is interpreted as the current directory (the
same as .). To retrieve additional matching filenames, call the Dir function again,
omitting the pathname and attributes arguments. If no file is found, an empty string
("") is returned.
Usage
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise, the function returns a variant of vartype 8 (string).
Example
See Also
3-80
ChDir Statement on page 3-35, ChDrive Statement on page 3-37, CurDir Function
on page 3-56, MkDir Statement on page 3-213, and RmDir Statement on page 3-275
Version 6.0
Do...Loop Statement
This standard VB control structure repeats a series of program lines as long as (or
until) an expression is TRUE.
Syntax A
Do [{ While|Until } condition]
statement_block
[Exit Do]
statement_block
Loop
Syntax B
Do
statement_block
[Exit Do]
statement_block
Loop [{ While|Until } condition]
Placeholder
Description
condition
statement_block
Returns
Not applicable
Usage
When an Exit Do statement is executed, control goes to the statement after the Loop
statement. When used within a nested loop, an Exit Do statement moves control
out of the immediately enclosing loop.
Example
For examples, see Dir Function on page 3-79, Eof Function on page 3-86, and Err
Function on page 3-91.
See Also
Exit Statement on page 3-98, Stop Statement on page 3-330, and While...Wend
Statement on page 3-369
Version 6.0
3-81
DoEvents Statement
Syntax
Argument
Description
Not applicable
Returns
Not applicable
Usage
DoEvents does not return until Windows has finished processing all events in the
queue and all keys sent by the SendKeys statement.
DoEvents should not be used if other tasks can interact with the running program
in unforeseen ways. Since Siebel VB yields control to the operating system at regular
intervals, DoEvents should only be used to force Siebel VB to allow other
applications to run at a known point in the program.
Example
This example activates the Windows Terminal application, dials the number and
then allows the operating system to process events.
Sub Button_Click
Dim phonenumber, msgtext
Dim x
phonenumber = InputBox("Enter telephone number to call:")
x = Shell("Terminal.exe",1)
SendKeys "%PD" & phonenumber & "{Enter}",1
msgtext = "Dialing..."
MsgBox msgtext
DoEvents
End Sub
See Also
3-82
AppActivate Statement on page 3-19, SendKeys Statement on page 3-291, and Shell
Function on page 3-302
Version 6.0
Drilldown Method
Drilldown navigates to the view that corresponds to the Drilldown object specified
as its argument. A Drilldown object is a child object of Applet. Drilldown is used
with applet objects. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-83
Environ Function
This standard VB function returns the string setting for a keyword in the operating
systems environment table.
Syntax A
Environ[$](environment-string)
Syntax B
Environ[$](numeric_expression)
Argument
Description
environment-string
numeric_expression
Returns
Usage
3-84
Version 6.0
Example
This example lists all the strings from the operating system environment table.
Sub Button_Click
Dim str1(100)
Dim msgtext
Dim count, x
Dim newline
newline = Chr(10)
x = 1
str1(x) = Environ(x)
Do While Environ(x) <> ""
str1(x) = Environ(x)
x = x + 1
str1(x) = Environ(x)
Loop
msgtext = "The Environment Strings are:" & newline & newline
count = x
For x = 1 to count
msgtext = msgtext & str1(x) & newline
Next x
MsgBox msgtext
End Sub
Version 6.0
3-85
Eof Function
This standard VB function is used to determine whether the end of an open file has
been reached.
Eof(filenumber)
Syntax
Argument
Description
filenumber
The file number used in the Open statement to open the file
Returns
The value -1 if the end of the specified open file has been reached, 0 otherwise.
Usage
See the Open Statement on page 3-238 for more information about assigning
numbers to files when they are opened.
Example
This example uses the Eof function to read records from a Random file, using a Get
statement. The Eof function keeps the Get statement from attempting to read
beyond the end of the file. The subprogram, CreateFile, creates the file
C:\TEMP001 used by the main subprogram. For another example, see the
FileDateTime Function on page 3-105.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
' Put the numbers 1-10 into a file
Dim x as Integer
Open "C:\TEMP001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End Sub
3-86
Version 6.0
Sub Button_Click
Dim acctno
Dim msgtext as String
newline = Chr(10)
Call CreateFile
Open "C:\temp001" For Input As #1
msgtext = "The account numbers are:" & newline
Do While Not Eof(1)
Input #1,acctno
msgtext = msgtext & newline & acctno & newline
Loop
MsgBox msgtext
Close #1
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
Get Statement on page 3-132, Input Function on page 3-156, Input Statement on
page 3-158, Line Input Statement on page 3-195, Loc Function on page 3-197, Lof
Function on page 3-200, and Open Statement on page 3-238
3-87
Erase Statement
This standard VB statement reinitializes the contents of a fixed array or frees the
storage associated with a dynamic array.
Erase Array[, Array]
Syntax
Argument
Description
Array
Returns
Not applicable
Usage
The effect of using Erase on the elements of a fixed array varies with the type of the
element:
3-88
Element Type
Erase Effect
Numeric
Variable-length string
Fixed-length string
Variant
User-defined type
Object
Version 6.0
Example
This example prompts for a list of item numbers to put into an array and clears the
array if the user wants to start over.
Sub Button_Click
Dim msgtext
Dim inum(100) as Integer
Dim x, count
Dim newline
newline = Chr(10)
x = 1
count = x
inum(x) = 0
Do
inum(x) = InputBox("Enter item #" & x & " (99 = start _
over;0 = end):")
If inum(x) = 99 then
Erase inum()
x = 0
ElseIf inum(x) = 0 then
Exit Do
End If
x = x + 1
Loop
count = x-1
msgtext = "You entered the following numbers:" & newline
For x = 1 to count
msgtext = msgtext & inum(x) & newline
Next x
MsgBox msgtext
End Sub
See Also
Version 6.0
Dim Statement on page 3-73, LBound Function on page 3-185, ReDim Statement on
page 3-263, and UBound Function on page 3-357
3-89
Erl Function
This standard VB function returns the line number where an error was trapped.
Erl
Syntax
Argument
Description
Not applicable
Returns
Usage
If you use a Resume or On Error statement after Erl, the return value for Erl is reset
to 0. To maintain the value of the line number returned by Erl, assign it to a variable.
The value of the Erl function can be set indirectly through the Error statement.
Example
This example prints the error number using the Err function and the line number
using the Erl statement if an error occurs during an attempt to open a file. Line
numbers are automatically assigned, starting with 1, which is the Sub
Button_Click statement.
Sub Button_Click
Dim msgtext, userfile
On Error GoTo Debugger
msgtext = "Enter the filename to use:"
userfile = InputBox$(msgtext)
Open userfile For Input As #1
MsgBox "File opened for input."
' ....etc....
Close #1
done:
Exit Sub
Debugger:
msgtext = "Error number " & Err & " occurred at line: " & Erl
MsgBox msgtext
Resume done
End Sub
See Also
3-90
Err Function on page 3-91, Err Statement on page 3-92, Error Function on
page 3-94, Error Statement on page 3-96, On Error Statement on page 3-235,
Resume Statement on page 3-271, and Appendix B, Trappable Errors
Version 6.0
Err Function
This standard VB function returns the run-time error code for the last error trapped.
Syntax
Err
Argument
Description
Not applicable
Returns
The run-time error code for the last standard VB error trapped.
Usage
If you use a Resume or On Error statement after Erl, the return value for Err is reset
to 0. To maintain the value of the line number returned by Erl, assign it to a variable.
The value of the Err function can be set directly through the Err statement, and
indirectly through the Error statement.
The standard VB trappable errors are listed in Appendix B, Trappable Errors.
Caution: You cannot view Siebel VB errors with this function.
Instead, use the appropriate method for the Siebel interface you are
using (COM, ActiveX, or CORBA). Error trapping methods and
examples for each interface are documented in the Siebel Object
Interfaces Reference.
Example
For examples, see Erl Function on page 3-90 and Error Function on page 3-94.
See Also
Erl Function on page 3-90, Err Statement on page 3-92, Error Function on page 3-94,
Error Statement on page 3-96, On Error Statement on page 3-235, Resume
Statement on page 3-271, and Appendix B, Trappable Errors
Version 6.0
3-91
Err Statement
Syntax
Argument
Description
errornumber
Returns
Not applicable
Usage
Example
This example generates an error code of 10000 and displays an error message if a
user does not enter a customer name when prompted for it. It uses the Err statement
to clear any previous error codes before running the loop the first time and it also
clears the error to allow the user to try again. For another example, see the Error
Statement on page 3-96.
Sub Button_Click
Dim custname as String
On Error Resume Next
Do
Err = 0
custname = InputBox$("Enter customer name:")
If custname = "" then
Error 10000
Else
Exit Do
End If
Select Case Err
Case 10000
MsgBox "You must enter a customer name."
Case Else
MsgBox "Undetermined error. Try again."
End Select
Loop Until custname <> ""
MsgBox "The name is: " & custname
End Sub
3-92
Version 6.0
See Also
Version 6.0
Erl Function on page 3-90, Err Function on page 3-91, Error Function on page 3-94,
Error Statement on page 3-96, On Error Statement on page 3-235, Resume
Statement on page 3-271, and Appendix B, Trappable Errors
3-93
Error Function
This standard VB function returns the error message that corresponds to the
specified error code.
Error[$] [(errornumber)]
Syntax
Returns
Argument
Description
errornumber
The text of the error message corresponding to the error code; if this argument is
omitted, Siebel VB returns the error message for the run-time error that has
occurred most recently.
If no error message is found to match the error code, a null string ("") is returned.
Usage
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
The standard VB trappable errors are listed in Appendix B, Trappable Errors.
Caution: You cannot view Siebel VB errors with this function.
Instead, use the GetLastErrorText method, which is documented in
the Siebel Object Interfaces Reference.
3-94
Version 6.0
Example
This example prints the error number, using the Err function, and the text of the
error, using the Error$ function, if an error occurs during an attempt to open a file.
Sub Button_Click
Dim msgtext, userfile
On Error GoTo Debugger
msgtext = "Enter the filename to use:"
userfile = InputBox$(msgtext)
Open userfile For Input As #1
MsgBox "File opened for input."
' ....etc....
Close #1
done:
Exit Sub
Debugger:
msgtext = "Error " & Err & ": " & Error$
MsgBox msgtext
Resume done
End Sub
See Also
Version 6.0
Erl Function on page 3-90, Err Function on page 3-91, Err Statement on page 3-92,
Error Statement on page 3-96, On Error Statement on page 3-235, Resume
Statement on page 3-271, and Appendix B, Trappable Errors
3-95
Error Statement
Usage
Error errornumber
Argument
Description
errornumber
If an errornumber is one that Siebel VB already uses, the Error statement will
simulate an occurrence of that error.
User-defined error codes should employ values greater than those used for standard
Siebel VB error codes. To help ensure that non-Siebel VB error codes are chosen,
user-defined codes should work down from 32,767.
Caution: Error codes for the Siebel VB methods described in the
Siebel Object Interfaces Reference are between 4000 and 4999. Do
not use codes in this range for user-defined error codes.
3-96
Version 6.0
Example
This example generates an error code of 10000 and displays an error message if a
user does not enter a customer name when prompted for it.
Sub Button_Click
Dim custname as String
On Error Resume Next
Do
Err = 0
custname = InputBox$("Enter customer name:")
If custname = "" then
Error 10000
Else
Exit Do
End If
Select Case Err
Case 10000
MsgBox "You must enter a customer name."
Case Else
MsgBox "Undetermined error. Try again."
End Select
Loop Until custname <> ""
MsgBox "The name is: " & custname
End Sub
See Also
Erl Function on page 3-90, Err Function on page 3-91, Err Statement on page 3-92,
Error Function on page 3-94, Error Statement on page 3-96, On Error Statement on
page 3-235, Resume Statement on page 3-271, and Appendix B, Trappable Errors
ExecuteQuery Method
ExecuteQuery2 Method
Version 6.0
3-97
Exit Statement
Returns
Not applicable
Usage
Use Exit Do inside a Do...Loop statement. Use Exit For inside a For...Next statement.
When the Exit statement is executed, control transfers to the statement after the
Loop or Next statement. When used within a nested loop, an Exit statement moves
control out of the immediately enclosing loop.
Use Exit Function inside a Function...End Function procedure. Use Exit Sub inside
a Sub...End Sub procedure.
Example
This example uses the On Error statement to trap run-time errors. If there is an error,
the program execution continues at the label Debugger. The example uses the Exit
statement to skip over the debugging code when there is no error.
Sub Button_Click
Dim msgtext, userfile
On Error GoTo Debugger
msgtext = "Enter the filename to use:"
userfile = InputBox$(msgtext)
Open userfile For Input As #1
MsgBox "File opened for input."
' ....etc....
Close #1
done:
Exit Sub
Debugger:
msgtext = "Error " & Err & ": " & Error$
MsgBox msgtext
Resume done
End Sub
See Also
3-98
Version 6.0
Exp Function
This standard VB function returns the value e (the base of natural logarithms) raised
to a power.
Syntax
Exp(number)
Argument
Description
number
Returns
Usage
If the variable to contain the return value has a data type of integer, currency, or
single, the return value is a single-precision value. If the variable has a data type of
long, variant, or double, the value returned is a double-precision number.
The constant e is approximately 2.718282.
Example
This example estimates the value of a factorial of a number entered by the user. A
factorial (notated with an exclamation mark, !) is the product of a number and each
integer between it and the number 1. For example, 5 factorial, or 5!, is the product
of 5*4*3*2*1, or the value 120.
Sub Button_Click
Dim x as Single
Dim msgtext, PI
Dim factorial as Double
PI = 3.14159
i: x = InputBox("Enter an integer between 1 and 88: ")
If x< = 0 then
Exit Sub
ElseIf x>88 then
MsgBox "The number you entered is too large. Try again."
Goto i
End If
factorial = Sqr(2 * PI * x) * (x^x/Exp(x))
msgtext = "The estimated factorial is: " & Format _
(factorial, "Scientific")
MsgBox msgtext
End Sub
Version 6.0
3-99
See Also
3-100
Abs Function on page 3-16, Fix Function on page 3-109, Int Function on page 3-166,
Log Function on page 3-201, Rnd Function on page 3-277, Sgn Function on
page 3-301, and Sqr Function on page 3-327
Version 6.0
FileAttr Function
This standard VB function returns the file mode or the operating system handle for
an open file.
Syntax
FileAttr(filenumber, returntype)
Argument
Description
filenumber
The file number used in the Open statement to open the file
returntype
Returns
If returntype is:
1
Returns:
The file mode of the open file, where
Usage
Version 6.0
The argument filenumber is the number used in the Open statement to open the file.
3-101
Example
This example closes an open file if it is open in input or output mode. If open in
append mode, it writes a range of numbers to the file. The second subprogram,
CreateFile, creates the file and leaves it open.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
End Sub
Sub Button_Click
Dim filemode as Integer
Dim attrib as Integer
Call CreateFile
attrib = 1
filemode = FileAttr(1,attrib)
If filemode = 1 or 2 then
MsgBox "File was left open. Closing now."
Close #1
Else
For x = 11 to 15
Write #1, x
Next x
Close #1
End If
Kill "c:\temp001"
End Sub
See Also
3-102
GetAttr Function on page 3-135, Open Statement on page 3-238, and SetAttr
Statement on page 3-297
Version 6.0
FileCopy Statement
Description
path1
The path of the file to copy (optional unless source$ is not in the current
directory)
source
path2
The path to the directory to which the file should be copied (optional unless
the file is to be copied to the current directory)
target
Returns
Not applicable
Usage
Wildcards (* and ?) are not allowed in any of the arguments. The source file cannot
be copied if it is opened by Siebel VB for anything other than Read access, or if it is
open in another program.
Example
This example copies one file to another. Both filenames are specified by the user.
Sub Button_Click
Dim oldfile, newfile
On Error Resume Next
oldfile = InputBox("Copy which file?")
newfile = InputBox("Copy to?")
FileCopy oldfile,newfile
If Err <> 0 then
msgtext = "Error during copy. Rerun program."
Else
msgtext = "Copy successful."
End If
MsgBox msgtext
End Sub
Version 6.0
3-103
See Also
3-104
Version 6.0
FileDateTime Function
This standard VB function returns the last modification date and time for the
specified file.
Syntax
FileDateTime(pathname)
Argument
Description
pathname
Returns
Usage
Pathname can contain path and disk information, but cannot include wildcards
(* and ?).
Example
This example writes data to a file if it hasnt been saved within the last two minutes.
Sub Button_Click
Dim tempfile
Dim filetime, curtime
Dim msgtext
Dim acctno(100) as Single
Dim x, I
tempfile = "C:\TEMP001"
Open tempfile For Output As #1
filetime = FileDateTime(tempfile)
x = 1
I = 1
acctno(x) = 0
Do
curtime = Time
acctno(x) = InputBox("Enter an account number (99 to end):")
If acctno(x) = 99 then
For I = 1 to x-1
Write #1, acctno(I)
Next I
Exit Do
ElseIf (Minute(filetime) + 2)< = Minute(curtime) then
For I = I to x
Write #1, acctno(I)
Next I
End If
x = x + 1
Version 6.0
3-105
Loop
Close #1
x = 1
msgtext = "Contents of C:\TEMP001 is:" & Chr(10)
Open tempfile for Input as #1
Do While Eof(1) <> -1
Input #1, acctno(x)
msgtext = msgtext & Chr(10) & acctno(x)
x = x + 1
Loop
MsgBox msgtext
Close #1
Kill "C:\TEMP001"
End Sub
See Also
3-106
Version 6.0
FileLen Function
FileLen(pathname)
Argument
Description
pathname
Returns
Usage
Pathname can contain path and disk information, but cannot include wildcards
(* and ?).
If the specified file is open, FileLen returns the length of the file before it was
opened.
Example
See Also
Version 6.0
FileDateTime Function on page 3-105, GetAttr Function on page 3-135, and Lof
Function on page 3-200
3-107
FindActiveXControl Method
FindApplet Method
FindControl Method
FindControl returns the control whose name is specified in the argument. This
applet must be part of the displayed view. It is used with applet objects. For details,
see the Siebel Object Interfaces Reference.
FirstRecord Method
FirstRecord moves to the first record in a Siebel business component, invoking any
associated Basic events. This method is used with business component objects. For
details, see the Siebel Object Interfaces Reference.
FirstSelected Method
FirstSelected moves the focus to the first record of the multiple selection in a Siebel
business component, invoking any associated Basic events. This method is used
with business component objects. For details, see the Siebel Object Interfaces
Reference.
3-108
Version 6.0
Fix Function
Fix(number)
Argument
Description
number
Returns
Usage
The return values data type matches the type of the numeric expression. This
includes variant expressions, unless the numeric expression is a string (vartype 8)
that evaluates to a number, in which case the data type for its return value is vartype
5 (double). If the numeric expression is vartype 0 (empty), the data type for the
return value is vartype 3 (long).
For both positive and negative numbers, Fix removes the fractional part of the
expression and returns the integer part only. For example, Fix (6.2) returns 6;
Fix (-6.2) returns -6.
NOTE: The effect of this function is the same as that of the Int function, except in
the handling of negative numbers. Thus:
Fix(-8.347) = -8
Int(-8.347) = -9
Version 6.0
3-109
Example
This example returns the integer portion of a number provided by the user.
Sub Button_Click
Dim usernum
Dim intvalue
usernum = InputBox("Enter a number with decimal places:")
intvalue = Fix(usernum)
MsgBox "The integer portion of " & usernum & " is: " & intvalue
End Sub
See Also
3-110
Abs Function on page 3-16, CInt Function on page 3-40, Exp Function on page 3-99,
Int Function on page 3-166, Log Function on page 3-201, Rnd Function on
page 3-277, Sgn Function on page 3-301, and Sqr Function on page 3-327
Version 6.0
For...Next Statement
This standard VB control structure repeats a series of program lines a fixed number
of times.
Syntax
Description
counter
start
end
increment
The amount by which the counter is changed each time the loop is
run; the default is 1
statement_block
Returns
Not applicable
Usage
The start and end values must be consistent with increment. If end is greater than
start, increment must be positive. If end is less than start, increment must be
negative. Siebel VB compares the sign of (start - end) with the sign of increment. If
the signs are the same, and end does not equal start, the For...Next loop is started.
If not, the loop is omitted in its entirety.
Version 6.0
3-111
With a For...Next loop, the program lines following the For statement are executed
until the Next statement is encountered. At this point, the Step amount is added to
the counter and compared with the final value, end. If the beginning and ending
values are the same, the loop executes once, regardless of the Step value. Otherwise,
the Step value controls the loop as follows:
Step Value
Loop Execution
Positive
If counter is less than or equal to end, the Step value is added to counter.
Control returns to the statement after the For statement and the process
repeats. If counter is greater than end, the loop is exited; execution resumes
with the statement following the Next statement.
Negative
Zero
Within the loop, the value of the counter should not be changed, as changing the
counter will make programs more difficult to maintain and debug.
For...Next loops can be nested within one another. Each nested loop should be given
a unique variable name as its counter. The Next statement for the inside loop must
appear before the Next statement for the outside loop. The Exit For statement can
be used as an alternative exit from For...Next loops.
If the variable is left out of a Next statement, the Next statement will match the most
recent For statement. If a Next statement occurs prior to its corresponding For
statement, Siebel VB will return an error message.
Multiple consecutive Next statements can be merged together. If this is done, the
counters must appear with the innermost counter first and the outermost counter
last. For example:
For i = 1 To 10
statement_block
For j = 1 To 5
statement_block
Next j, i
Example
3-112
Version 6.0
See Also
Version 6.0
Do...Loop Statement on page 3-81, Exit Statement on page 3-98, and While...Wend
Statement on page 3-369
3-113
Format Function
Format[$](expression[, format])
Argument
Description
expression
format
Select one of the topics below for a detailed description of format strings.
Returns
Usage
Format formats the expression as a number, date, time, or string depending upon
the format argument. The dollar sign ($) in the function name is optional. If it is
included, the return type is string. Otherwise the function returns a variant of
vartype 8 (string). As with any string, you must enclose the format argument in
quotation marks ("").
Numeric values are formatted as either numbers or date/times. If a numeric
expression is supplied and the format argument is omitted or null, the number will
be converted to a string without any special formatting.
Both numeric values and variants can be formatted as dates. When formatting
numeric values as dates, the value is interpreted according the standard Basic date
encoding scheme. The base date, December 30, 1899, is represented as zero, and
other dates are represented as the number of days from the base date.
Strings are formatted by transferring one character at a time from the input
expression to the output string.
3-114
Version 6.0
Formatting Numbers
The predefined numeric formats with their meanings are as follows:
Version 6.0
Format
Description
General
Number
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 thousand separator and two digits to the right
of decimal separator.
Scientific
Currency
Percent
True/False
Yes/No
On/Off
3-115
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
Format
Result
1234567.8901
#,#.##
1,234,567.89
1234567.8901
#,#.####
1,234,567.8901
NOTE: Although a comma and period are used in the format specification to denote
separators for thousands and decimals, the output string will contain the
appropriate character, based upon the current international settings for your
machine.
3-116
Version 6.0
Numbers can be scaled either by inserting one or more commas before the decimal
separator or by including a percent sign in the format specification. Each comma
preceding the decimal separator (or after all digits if no decimal separator is
supplied) will scale (divide) the number by 1000. The commas will not appear in
the output string. The percent sign will cause the number to be multiplied by 100.
The percent sign will appear in the output string in the same position as it appears
in format.
Number
Format
Result
1234567.8901
#,.##
1234.57
1234567.8901
#,,.####
1.2346
1234567.8901
#,#,.##
1,234.57
0.1234
#0.00%
12.34%
Characters can be inserted into the output string by being included in the format
specification. The following characters will be automatically inserted in the output
string in a location matching their position in the format specification:
- + $ ( space
Any set of characters can be inserted by enclosing them in double quotes. Any
single character can be inserted by preceding it with a backslash, \.
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 standard VB Chr function if you need to embed quotation marks in
a format specification. The character code for a quotation mark is 34.
Version 6.0
3-117
e-
e+
The exponent string should be preceded by one or more digit characters. The
number of digit characters following the exponent string determines the number of
exponent digits in the output. Format specifications containing an uppercase E will
result in an uppercase E in the output. Those containing a lowercase e will result
in a lowercase e in the output. A minus sign following the E will cause negative
exponents in the output to be preceded by a minus sign. A plus sign in the format
will cause a sign to always precede the exponent in the output.
3-118
Number
Format
Result
1234567.89
###.##E-00
123.46E04
1234567.89
###.##e + #
123.46e + 4
0.12345
0.00E-00
1.23E-01
Version 6.0
A numeric format can have up to four sections, separated by semicolons. If you use
only one section, it applies to all values. If you use two sections, the first section
applies to positive values and zeros, the second to negative values. If you use three
sections, the first applies to positive values, the second to negative values, and the
third to zeros. If you include semicolons with nothing between them, the undefined
section is printed using the format of the first section. The fourth section applies to
Null values. If it is omitted and the input expression results in a NULL value, Format
will return an empty string.
Version 6.0
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
0.00
3-119
Description
General Date
If the number has both integer and real parts, displays both date and
time (for example, 11/8/93 1:23:45 PM); if the number has only an
integer part, displays it as a date; if the number has only a fractional
part, displays it as time
Long Date
Medium Date
Displays the date using the month abbreviation, without the day of the
week (for example, 08-Nov-93)
Short Date
Long Time
Medium Time
Does not display seconds; displays hours in 12-hour format and uses the
AM/PM designator
Short Time
3-120
Version 6.0
Output
The equivalent of the format ddddd ttttt. See the definitions below
ddddd
The date including the day, month, and year according to the machines
current Short Date setting; the default Short Date setting for the United States
is m/d/yy
dddddd
The date including the day, month, and year according to the machines
current Long Date setting; the default Long Date setting for the United States
is mmmm dd, yyyy
ttttt
The time including the hour, minute, and second using the machines current
time settings; the default time format is h:mm:ss AM/PM
Finer control over the output is available by including format tokens that deal with
the individual components of the date-time. These tokens are:
Version 6.0
Token
Output
dd
ddd
dddd
ww
The month of the year or the minute of the hour as a one or two digit number.
The minute will be output if the preceding token was an hour; otherwise, the
month will be output
mm
The month or the year or the minute of the hour as a two digit number. The
minute will be output if the preceding token was an hour; otherwise, the month
will be output
mmm
mmmm
3-121
Token
Output
yy
yyyy
hh
nn
ss
By default, times will be displayed using a military (24-hour) clock. Several tokens
are provided in date time format specifications to change this default. They all cause
a 12 hour clock to be used. These are:
3-122
Token
Output
AM/PM
An uppercase AM with any hour before noon; an uppercase PM with any hour
between noon and 11:59 PM
am/pm
A lowercase am with any hour before noon; a lowercase pm with any hour
between noon and 11:59 PM
A/P
An uppercase A with any hour before noon; an uppercase P with any hour
between noon and 11:59 PM
a/p
A lowercase a with any hour before noon; a lowercase p with any hour
between noon and 11:59 PM
AMPM
The contents of the 1159 string (s1159) in the WIN.INI file with any hour
before noon; the contents of the 2359 string (s2359) with any hour between
noon and 11:59 PM. Note: ampm is equivalent to AMPM
Version 6.0
Any set of characters can be inserted into the output by enclosing them in double
quotes. Any single character can be inserted by preceding it with a backslash, \.
See number formatting above for more details.
Formatting Strings
By default, string formatting transfers characters from left to right. The exclamation
point, !, when added to the format specification causes characters to be transferred
from right to left. By default, characters being transferred will not be modified. The
less than, <, and the greater than, >, characters can be used to force case
conversion on the transferred characters. Less than forces output characters to be
in lowercase. Greater than forces output characters to be in uppercase.
Character transfer is controlled by the at sign, @, and the ampersand, &, characters
in the format specification. These operate as follows:
Character
Interpretation
&
A format specification for strings can have one or two sections separated by a
semicolon. If you use one section, the format applies to all string data. If you use
two sections, the first section applies to string data, the second to Null values and
zero-length strings.
Version 6.0
3-123
Examples
Figure 3-1.
Formatting Strings
Figure 3-2.
3-124
Formatting Numbers
Version 6.0
This example uses several different date-formatting tokens to format the result of
the Now function, which returns the current date and time on the system clock. The
result is shown in Figure 3-3.
Sub ClickMe_Click
dim msgtext As String
msgtext = Now & Chr$(13) & Chr$(13) _
& "Today is " & Format(Now, "dddd") & ", " _
& Format(Now, "mmmm") & " " & Format(Now, "dd") & ", " _
& Format(Now, "yyyy") & "." _
& Chr$(13) & "The time is " & Format(Now, "h:nn am/pm") _
& " and " & Format(Now, "s") & " seconds."
MsgBox msgtext, mbOKOnly, "Now"
End Sub
Figure 3-3.
For other examples of the Format function, see the CCur Function on page 3-32, the
FV Function on page 3-130, and the GoTo Statement on page 3-148.
See Also
Version 6.0
Asc Function on page 3-22, CCur Function on page 3-32, CDbl Function on
page 3-34, Chr Function on page 3-38, CInt Function on page 3-40, CLng Function
on page 3-44, CSng Function on page 3-52, CStr Function on page 3-54, CVar
Function on page 3-58, CVDate Function on page 3-59, and Str Function on
page 3-331
3-125
FreeFile Function
FreeFile
Argument
Description
Not applicable
Returns
Usage
The FreeFile function is used when you need to supply a file number and want to
make sure that you are not choosing a file number that is already in use.
The value returned can be used in a subsequent Open statement.
Example
This example opens a file and assigns to it the next file number available.
Sub Button_Click
Dim filenumber As Integer
Dim filename As String
filenumber = FreeFile
filename = InputBox("Enter a file to open: ")
On Error Resume Next
Open filename For Input As filenumber
If Err <> 0 then
MsgBox "Error loading file. Re-run program."
Exit Sub
End If
MsgBox "File " & filename & " opened as number: " & _
filenumber
Close #filenumber
MsgBox "File now closed."
End Sub
See Also
3-126
Version 6.0
Description
name
parameter
type
funcType
Returns
The value calculated by the expression; the program line name = expression assigns
the return value to the name of the function.
Usage
The purpose of a function is to produce and return a single value of a specified type.
Recursion is supported.
The data type of name determines the type of the return value. Use a type character
as part of the name, or use the As funcType clause to specify the data type.
Otherwise the default data type is variant. When calling the function, you need not
specify the type character.
The parameters are specified as a comma-separated list of variable names. The data
type of a parameter can be specified by using a type character or by using the As
clause. Record parameters are declared using an As clause and a type that has
previously been defined using the Type statement. Array parameters are indicated
by using empty parentheses after the parameter. The array dimensions are not
specified in the Function statement. All references to an array parameter within the
body of the function must have a consistent number of dimensions.
Version 6.0
3-127
You specify the return value for the function name using the name = expression
assignment, where name is the name of the function and expression evaluates to a
return value. If omitted, the value returned is 0 for numeric functions and an empty
string ("") for string functions and vartype 0 (Empty) is returned for a return type
of variant. The function returns to the caller when the End Function statement is
reached or when an Exit Function statement is executed.
If you declare a parameter as Optional, a procedure can omit its value when calling
the function. Only parameters with variant data types can be declared as optional,
and all optional arguments must appear after all required arguments in the Function
statement. The function IsMissing must be used to check whether an optional
parameter was omitted by the user or not. Named parameters are described under
the Call statement heading, but they can be used when the function is used in an
expression as well.
The Static keyword specifies that all the variables declared within the function will
retain their values as long as the program is running, regardless of the way the
variables are declared.
The Private keyword specifies that the function will not be accessible to functions
and subprograms from other modules. Only procedures defined in the same module
will have access to a Private function.
Basic procedures use the call by reference convention. This means that if a
procedure assigns a value to a parameter, it will modify the variable passed by the
caller. This feature should be used with great care.
Use Sub to define a procedure with no return value.
Caution: You cannot write your own functions or subprograms
directly in the methods and events exposed in Siebel Tools. You can
write functions and subprograms in the (general) (declarations)
section of a given method script. However, if you want your routines
to be available throughout the program, you can use the
Application_PreInvokeMethod or an external .DLL file as a central
place to write them. See Siebel Tech Notes #207 and #217 for details.
3-128
Version 6.0
NOTE: If you create more than one function or subprogram in the (general)
(declarations) section, be sure that any function or subprogram that may be called
by other user-defined functions and subprograms appears before the procedure that
calls it. Otherwise, you will not be able to compile your procedures.
Example
This example declares a function that is later called by the main subprogram. The
function performs a calculation on the value sent to it, thereby changing the value
of the variable. For other examples, see Declare Statement on page 3-68, and the
second example under GoTo Statement on page 3-148.
(general) (declarations)
Option Explicit
Declare Function Calculate(i as Single) As Single
Function Calculate(i As Single)
i = i * 3 + 2
Calculate = i
End Function
Sub Button_Click
Dim x as String
Dim y As Single
x = InputBox("Enter a number:")
y = val(x)
Call Calculate(y)
MsgBox "The value returned by the function is: " & y
End Sub
See Also
Version 6.0
Call Statement on page 3-29, Dim Statement on page 3-73, Global Statement on
page 3-144, IsMissing Function on page 3-177, Option Explicit Statement on
page 3-246, Static Statement on page 3-328, and Sub...End Sub Statement on
page 3-336
3-129
FV Function
This standard VB function returns the future value for a constant periodic stream of
cash flows as in an annuity or a loan.
Syntax
Description
rate
nper
pmt
pv
The present value or the initial lump sum amount paid (as in the case of an
annuity) or received (as in the case of a loan)
due
An integer value indicating when the payments are due (0 = end of each
period, 1 = beginning of the period)
Returns
Usage
The given interest rate is assumed constant over the life of the annuity.
If payments are on a monthly schedule and the annual percentage rate on the
annuity or loan is 9%, the rate is 0.0075 (.0075 = .09/12).
3-130
Version 6.0
Example
This example finds the future value of an annuity, based on terms specified by the
user.
Sub Button_Click
Dim aprate, periods
Dim payment, annuitypv
Dim due, futurevalue
Dim msgtext
annuitypv = InputBox("Enter present value of the annuity: ")
aprate = InputBox("Enter the annual percentage rate: ")
If aprate >1 then
aprate = aprate/100
End If
periods = InputBox("Enter the total number of pay periods: ")
payment = InputBox("Enter the initial amount paid to you: ")
' Assume payments are made at end of month
due = 0
futurevalue = FV(aprate/12,periods,-payment,-annuitypv,due)
msgtext = "The future value is: " & Format(futurevalue,
"Currency")
MsgBox msgtext
End Sub
See Also
Version 6.0
IPmt Function on page 3-169, IRR Function on page 3-171, NPV Function on
page 3-227, Pmt Function on page 3-249, PPmt Function on page 3-252, PV
Function on page 3-258, and Rate Function on page 3-261
3-131
Get Statement
This standard VB function reads data from a file opened in Random or Binary mode
and puts it in a variable.
Syntax
Description
filenumber
The file number used in the Open statement to open the file
recnumber
varName
The name of the variable into which Get reads file data; varName can be
any variable except Object or Array variables, although single array
elements can be used
Returns
Not applicable
Usage
For more information about how files are numbered when they are opened, see the
Open statement.
Recnumber is in the range 1 to 2,147,483,647. If this argument is omitted, the next
record or byte is read.
NOTE: The commas before and after the recnumber are required, even if you do not
supply a recnumber.
For Random mode, the following rules apply:
Blocks of data are read from the file in chunks whose size is equal to the size
specified in the Len clause of the Open statement. If the size of varName is smaller
than the record length, the additional data is discarded. If the size of varName is
larger than the record length, an error occurs.
For variable length string variables, Get reads two bytes of data that indicate the
length of the string, then reads the data into varName.
3-132
Version 6.0
For variant variables, Get reads two bytes of data that indicate the type of the
variant, then it reads the body of the variant into varName. Note that variants
containing strings contain two bytes of data type information followed by two bytes
of length followed by the body of the string.
User defined types are read as if each member were read separately, except no
padding occurs between elements.
Files opened in Binary mode behave similarly to those opened in Random mode,
except that:
This example opens a file for Random access, gets its contents, and closes the file
again. The second subprogram, createfile, creates the c:\temp001 file used
by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
' Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End Sub
Sub Button1_Click
Dim acctno as String * 3
Dim recno as Long
Dim msgtext as String
Call CreateFile
recno = 1
newline = Chr(10)
Open "c:\temp001" For Random As #1 Len = 3
msgtext = "The account numbers are:" & newline
Version 6.0
3-133
Do Until recno = 11
Get #1,recno,acctno
msgtext = msgtext & acctno
recno = recno + 1
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
Open Statement on page 3-238, Put Statement on page 3-256, and Type Statement
on page 3-354
GetAssocBusComp Method
3-134
Version 6.0
GetAttr Function
This standard VB function returns the attributes of a file, directory, or volume label.
Syntax
Returns
Usage
GetAttr(pathname)
Argument
Description
pathname
An integer representing a file attribute. The file attributes returned by GetAttr are as
follows:
Value
Meaning
Normal file
Read-only file
Hidden file
System file
Volume label
16
Directory
32
Pathname can contain drive and directory information, but cannot contain
wildcards (* and ?).
If GetAttr returns a value other than those listed above, the return value represents
the sum of the return values for those attributes that are set; thus, for example, a
return value of 6 represents a hidden system file.
Version 6.0
3-135
Example
This example tests the attributes for a file and if it is hidden, changes it to a nonhidden file.
Sub Button_Click
Dim filename as String
Dim attribs, saveattribs as Integer
Dim answer as Integer
Dim archno as Integer
Dim msgtext as String
archno = 32
On Error Resume Next
msgtext = "Enter name of a file:"
filename = InputBox(msgtext)
attribs = GetAttr(filename)
If Err <> 0 then
MsgBox "Error in filename. Re-run Program."
Exit Sub
End If
saveattribs = attribs
If attribs> = archno then
attribs = attribs-archno
End If
Select Case attribs
Case 2,3,6,7
msgtext = " File: " &filename & " is hidden." & Chr(10)
msgtext = msgtext & Chr(10) & "Change it?"
answer = Msgbox(msgtext,308)
If answer = 6 then
SetAttr filename, saveattribs-2
Msgbox "File is no longer hidden."
Exit Sub
End If
MsgBox "Hidden file not changed."
Case Else
MsgBox "File was not hidden."
End Select
End Sub
See Also
3-136
Version 6.0
GetBusComp Method
GetBusObject Method
GetChild Method
GetChild returns a specified child property set of a property set. For details, see the
Siebel Object Interfaces Reference.
GetChildCount Method
GetFieldValue Method
GetFieldValue returns the value for the argument-specified field for the current
record of a Siebel business component. Use this method to access a field value. This
method is used with business component objects. For details, see the Siebel Object
Interfaces Reference.
Version 6.0
3-137
GetFirstProperty Method
GetFormattedFieldValue Method
GetFormattedFieldValue returns the field value in the current local format; it returns
values in the same format as the Siebel UI. It is used with business component
objects. For details, see the Siebel Object Interfaces Reference.
GetMVGBusComp Method
GetNamedSearch Method
GetNextProperty Method
Once the name of the first property has been retrieved, this method retrieves the
name of the next property of a business service. For details, see the Siebel Object
Interfaces Reference
3-138
Version 6.0
GetObject Function
This standard VB function returns a COM object associated with the file name or
the application name.
Syntax A
GetObject(pathname)
Syntax B
GetObject(pathname, class)
Syntax C
GetObject(, class)
Argument
Description
pathname
class
Returns
The object associated with pathname or the object associated with class.
Usage
Use GetObject with the Set statement to assign a variable to the object for use in a
Basic procedure. The variable used must first be dimensioned as an object.
Syntax A of GetObject accesses a COM object stored in a file. For example, the
following two lines dimension a variable as an object and assign the object
payables.xls to it. Payables.xls is located in the subdirectory My
Documents:
Dim oFileObject As Object
Set oFileObject = GetObject("C:\My _
Documents\payables.xls")
If the application supports accessing component objects within the file, you can
append an exclamation point and a component object name to the file name, as
follows:
Dim oComponentObject As Object
Set oComponentObject = _
GetObject("C:\My Documents\payables.xls!R1C1: R13C9")
Version 6.0
3-139
The third form of GetObject accesses the active COM object of a particular class.
For example:
Dim oApplication As _
SiebelApplicationServer.SiebelApplication
Set oApplication = _
GetObject(,"SiebelAppServer.ApplicationObject")
If you use the third form of GetObject with an empty string ("") as the pathname,
a new object instance of the specified type is returned. Thus, the above example
will get an open instance of the Siebel application, whereas
Set oApplication = _
GetObject("","SiebelAppServer.ApplicationObject")
will instantiate the Siebel application in memory, independent of the user interface.
NOTE: The last two examples refer to the object SiebelAppServer, which has been
defined as an object type if you have configured your external Visual Basic
environment according to the directions found in Setting Up Microsoft Visual Basic
to Access the Siebel Applications on page 2-3.
3-140
Version 6.0
Example
This example opens a specific Excel worksheet and places the contents of the Name
field of the active business component in it. The worksheet file must already exist.
Sub Button1_Click
Dim ExcelSheet As Object
Set ExcelSheet = GetObject("C:\demo\test.xls")
'Make Excel visible through the Application object.
ExcelSheet.Application.Visible = 1
'Place some text in the first cell of the sheet.
ExcelSheet.ActiveSheet.Cells(1, 1).Value = _
theApplication.ActiveBusComp.GetFieldValue("Name")
'Save the sheet.
ExcelSheet.Save
'Close Excel with the Quit method on the Application object.
+ExcelSheet.Application.Quit
End Sub
See Also
GetPicklistBusComp Method
GetProfileAttr Method
GetProfileAttr returns the value of an attribute in a user profile.For details, see the
Siebel Object Interfaces Reference.
Version 6.0
3-141
GetProperty Method
The GetProperty method returns the value of the property whose name is specified
in its argument on the object on which it is invoked. For details, see the Siebel Object
Interfaces Reference.
GetSearchExpr Method
GetSearchSpec Method
GetSearchSpec returns the search specification for the field specified in its
argument. This method is used with business component objects. For details, see
the Siebel Object Interfaces Reference.
GetService Method
The GetService method returns a specified business service. If the service is not
already running, it will be constructed. For details, see the Siebel Object Interfaces
Reference.
GetSharedGlobal Method
The GetSharedGlobal method gets the shared user-defined global variables. The
SetSharedGlobal property sets the shared user-defined global variables. It is used
with the application object. For details, see the Siebel Object Interfaces Reference.
3-142
Version 6.0
GetType Method
GetType retrieves the value stored in the type attribute of a property set. For details,
see the Siebel Object Interfaces Reference.
GetUserProperty Method
GetValue Method
The GetValue method returns the value of a control in a Siebel applet, or of the value
attribute of a property set. If used with control objects, the type of the return value
depends on the specific control object. For details, see the Siebel Object Interfaces
Reference.
GetViewMode Method
GetViewMode returns the current visibility mode for a Siebel business component.
This affects which records are returned by queries according to the visibility rules.
This method is used with business component objects. For details, see the Siebel
Object Interfaces Reference.
Version 6.0
3-143
Global Statement
This standard VB statement declares Global variables for use in a Basic program.
Syntax
Description
variableName
A variable name
type
Returns
Not applicable
Usage
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: all variables must be given a data type or they
will be automatically 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:
Arrays
Numbers
Records
Strings
Variants
3-144
Version 6.0
Arrays
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:
Global variable([ subscriptRange, ... ]) [As typeName]
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.
Numbers
Numeric variables can be declared using the As clause and one of the following
numeric types: currency, integer, long, single, double. Numeric variables can also
be declared by including a type character as a suffix to the name.
Records
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:
Global variableName As typeName
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. See the Type
Statement on page 3-354 for details on accessing fields within a record.
You cannot use the Global statement to declare a dialog record.
Version 6.0
3-145
Strings
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:
Global variableName 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:
Global variableName$
or
Global variableName As String
Variants
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:
Global variableName
or
GlobalvariableName As Variant
This example contains two subroutines that share the variables total and acctno,
and the record grecord.
(general)(declarations)
Option Explicit
Type acctrecord
acctno As Integer
End Type
3-146
Version 6.0
See Also
Version 6.0
Const Statement on page 3-47, Dim Statement on page 3-73, Option Base Statement
on page 3-241, ReDim Statement on page 3-263, Static Statement on page 3-328,
and Type Statement on page 3-354
3-147
GoTo Statement
GoTo label
Argument
Description
label
A name beginning in the first column of a line of code and ending in a colon (:)
Returns
Not applicable
Usage
A label has the same format as any other Basic name. Reserved words are not valid
labels.
GoTo cannot be used to transfer control out of the current Function or Subprogram.
Example
This example displays the date for one week from the date entered by the user. If
the date is invalid, the GoTo statement sends program execution back to the
beginning.
Sub Button_Click
Dim str1 as String
Dim nextweek
Dim msgtext
start:
str1 = InputBox("Enter a date:")
answer = IsDate(str1)
If answer = -1 then
str1 = CVDate(str1)
nextweek = DateValue(str1) + 7
msgtext = "One week from the date entered is "
msgtext = msgtext & Format(nextweek,"dddddd")
MsgBox msgtext
Else
MsgBox "Invalid date or format. Try again."
GoTo start
End If
End Sub
3-148
Version 6.0
(general) (declarations)
Option Explicit
' Variables must be declared in this section so that they
' can be used by both procedures.
Dim str1 As String, nextweek, MsgText As String
Declare Function CheckResponse(Answer) As String
Function CheckResponse(Answer) As String
str1 = CVDate(str1)
nextweek = DateValue(str1) + 7
CheckResponse = "One week from the date entered is " & _
Format(nextweek, "dddddd")
End Function
Sub Button1_Click
Dim Answer as String
str1 = InputBox("Enter a date:")
Answer = IsDate(str1)
If Answer <> -1 Then
MsgText = "Invalid date or format. Try again."
MsgBox MsgText
Button1_Click
Else
MsgBox CheckResponse(Answer)
End If
End Sub
See Also
Version 6.0
3-149
GotoApplet Method
The GotoApplet method sets the focus to the specified applet. It is used with the
application object. For details, see the Siebel Object Interfaces Reference.
GotoControl Method
GotoControl navigates to the control specified in its argument. This method is used
with the application object. For details, see the Siebel Object Interfaces Reference.
GotoView Method
GotoView activates the named view and its business object. As a side effect, this
method activates the views primary applet and its business component and
activates the primary applets first tab sequence control. Further, this method
deactivates any business object, business component, applet, or control objects that
were active prior to this method call. It is used with the application object. For
details, see the Siebel Object Interfaces Reference.
3-150
Version 6.0
Hex Function
Hex[$](number)
Argument
Description
number
Returns
Usage
Example
This example returns the hex value for a number entered by the user.
Sub Button_Click
Dim usernum as Integer
Dim hexvalue
usernum = InputBox("Enter a number to convert to hexidecimal:")
hexvalue = Hex(usernum)
Msgbox "The HEX value is: " & hexvalue
End Sub
See Also
Version 6.0
3-151
Hour Function
Hour(time)
Argument
Description
time
Returns
If the expression evaluates to a date-time or time value, the hour component of that
value; otherwise 0.
Usage
Time can be any type, including string, and Hour will attempt to convert time to a
date value.
The return value is a variant of vartype 2 (integer). If the value of time is Null, a
variant of vartype 1 (null) is returned.
In order for Hour to function without an error, the values passed to it must be in
some form that can be interpreted as a time or date-time value. Thus, 13:26, or
1:45:12 PM will return valid results, but 1326 will return a 0.
Time is a double-precision value. The numbers to the left of the decimal point
denote the date and the decimal value denotes the time (from 0 to .99999). Use the
TimeValue function to obtain the correct value for a specific time.
3-152
Version 6.0
Example
This example extracts just the time (hour, minute, and second) from a files last
modification date and time.
Sub Button_Click
Dim filename as String
Dim ftime
Dim hr, min
Dim sec
Dim msgtext as String
TryAgain:
msgtext = "Enter a filename:"
filename = InputBox(msgtext)
If filename = "" then
Exit Sub
End If
On Error Resume Next
ftime = FileDateTime(filename)
If Err <> 0 then
MsgBox "Error in file name. Try again."
Goto TryAgain:
End If
hr = Hour(ftime)
min = Minute(ftime)
sec = Second(ftime)
Msgbox "The file's time is: " & hr &":" &min &":" &sec
End Sub
See Also
Version 6.0
3-153
If...Then...Else Statement
Syntax B
If condition Then
statement_block
[ElseIf expression Then
statement_block ]...
[Else
statement_block ]
End If
Placeholder
Description
condition
then_statement
else statement
expression
statement_block
Returns
Not applicable
Usage
When multiple statements are required in either the Then or Else clause, use the
block version (Syntax B) of the If statement.
3-154
Version 6.0
Example
This example checks the time and the day of the week and returns an appropriate
message.
Sub Button_Click
Dim h, m, m2, w
h = hour(now)
If h > 18 then
m = "Good evening, "
Elseif h >12 then
m = "Good afternoon, "
Else
m = "Good morning, "
End If
w = weekday(now)
If w = 1 or w = 7
Then m2 = "the office is closed."
Else m2 = "please hold for company operator."
Msgbox m & m2
End If
End Sub
See Also
Version 6.0
3-155
Input Function
This standard VB function returns a string containing the characters read from a file.
Syntax
Input[$](number, [#]filenumber)
Argument
Description
number
filenumber
Returns
Usage
The file pointer is advanced the number of characters read. Unlike the Input
statement, Input returns all characters it reads, including carriage returns, line
feeds, and leading spaces.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
3-156
Version 6.0
Example
This example opens a file and prints its contents to the screen.
Sub Button_Click
Dim fname
Dim fchar()
Dim x as Integer
Dim msgtext
Dim newline
newline = Chr(10)
On Error Resume Next
fname = InputBox("Enter a filename to print:")
If fname = "" then
Exit Sub
End If
Open fname for Input as #1
If Err <> 0 then
MsgBox "Error loading file. Re-run program."
Exit Sub
End If
msgtext = "The contents of " & fname & " is: " _
& newline &newline
Redim fchar(Lof(1))
For x = 1 to Lof(1)
fchar(x) = Input(1,#1)
msgtext = msgtext & fchar(x)
Next x
MsgBox msgtext
Close #1
End Sub
See Also
Version 6.0
Get Statement on page 3-132, Input Statement on page 3-158, Line Input Statement
on page 3-195, Open Statement on page 3-238, and Write Statement on page 3-374
3-157
Input Statement
This standard VB statement reads data from a sequential file and assigns the data
to variables.
Syntax A
Syntax B
Description
filenumber
The file number used in the Open statement to open the file from which
to read
variable
One or more variables to contain the values read from the file
prompt
Returns
Not applicable
Usage
The filenumber is the number used in the Open statement to open the file. The list
of variables is separated by commas.
If filenumber is not specified, the user is prompted for keyboard input, either with
prompt or with a question mark (?) if prompt is omitted.
Example
This example prompts a user for an account number, opens a file, searches for the
account number, and displays the matching letter for that number. It uses the Input
statement to increase the value of x and at the same time get the letter associated
with each value. The second subprogram, CreateFile, creates the file
c:\temp001 used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Global x as Integer
Global y(100) as String
Sub CreateFile
' Put the numbers 1-10 and letters A-J into a file
Dim startletter
Open "c:\temp001" for Output as #1
startletter = 65
3-158
Version 6.0
For x = 1 to 10
y(x) = Chr(startletter)
startletter = startletter + 1
Next x
For x = 1 to 10
Write #1, x,y(x)
Next x
Close #1
End Sub
Sub Button2_Click
Dim acctno as Integer
Dim msgtext
Call CreateFile
start: acctno = InputBox("Enter an account number from 1-10:")
If acctno<1 Or acctno>10 then
MsgBox "Invalid account number. Try again."
Goto start:
End if
x = 1
Open "c:\temp001" for Input as #1
Do Until x = acctno
Input #1, x,y(x)
Loop
msgtext = "The letter for account number " & x & " is: " _
& y(x)
Close #1
MsgBox msgtext
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
Get Statement on page 3-132, Input Function on page 3-156, Line Input Statement
on page 3-195, Open Statement on page 3-238, and Write Statement on page 3-374
3-159
InputBox Function
This standard VB function displays a dialog box containing a prompt and returns a
string entered by the user. For compatibility with Siebel VB, InputBox can also be
accessed as a global method.
Syntax
Description
prompt
title
defaultText
xpos
ypos
Returns
A string containing the user input, or, if the user typed no input, the default input
value.
Usage
The length of prompt is restricted to 255 characters. This figure is approximate and
depends on the width of the characters used. Note that a carriage return and a linefeed character must be included in prompt if a multiple-line prompt is used.
If prompt is omitted, a run-time error occurs.
3-160
Version 6.0
Xpos determines the horizontal distance between the left edge of the screen and the
left border of the dialog box. Ypos determines the horizontal distance from the top
of the screen to the dialog boxs upper edge. If these arguments are not entered, the
dialog box is centered roughly one third of the way down the screen. A horizontal
dialog box unit is 1/4 of the average character width in the system font; a vertical
dialog box unit is 1/8 of the height of a character in the system font.
NOTE: If you want to specify the dialog boxs position, you must enter both of these
arguments. If you enter one without the other, the default positioning is set.
If the user presses Enter or clicks OK, InputBox returns the text contained in the
input box. If the user clicks Cancel, the InputBox function returns a null string ("").
Returns
Example
This example uses InputBox to prompt for a filename and then prints the filename
using MsgBox.
Sub Button_Click
Dim filename
Dim msgtext
msgtext = "Enter a filename:"
filename = InputBox$(msgtext)
MsgBox "The file name you entered is: " & filename
End Sub
See Also
Version 6.0
Input Function on page 3-156, Input Statement on page 3-158, Msgbox Function on
page 3-216, and Siebel Object Interfaces Reference.
3-161
InputBox Method
The InputBox method prompts the user for input and is similar to the Microsoft
Visual Basic InputBox method. Unlike the standard VB function, this method is
invoked upon an object instance, specifically, an instance of the application object.
For details, see the Siebel Object Interfaces Reference.
InsertChildAt Method
InsertChildAt inserts a child property set into a parent property set at a specific
location. For details, see the Siebel Object Interfaces Reference.
3-162
Version 6.0
InStr Function
This standard VB function returns the position of the first occurrence of one string
within another string.
Syntax A
Syntax B
Description
start
An integer representing the position in string1 to begin the search, with the
first character in the string as 1
string1
string2
compare
Returns
Usage
If not specified, the search starts at the beginning of the string (equivalent to a start
of 1). These arguments can be of any type. They will be converted to strings.
InStr returns a zero under the following conditions:
Version 6.0
3-163
This example generates a random string of characters, then uses InStr to find the
position of a single character within that string.
Sub Button_Click
Dim x as Integer
Dim y
Dim str1 as String
Dim str2 as String
Dim letter as String
Dim randomvalue
Dim upper, lower
Dim position as Integer
Dim msgtext, newline
upper = Asc("z")
lower = Asc("a")
newline = Chr(10)
For x = 1 to 26
Randomize
randomvalue = Int(((upper - (lower + 1)) * Rnd) + lower)
letter = Chr(randomvalue)
str1 = str1 & letter
'Need to waste time here for fast processors
For y = 1 to 1000
Next y
Next x
str2 = InputBox("Enter a letter to find")
position = InStr(str1,str2)
If position then
msgtext = "The position of " & str2 & " is: " _
& position & newline & "in string: " & str1
Else
msgtext = "The letter: " & str2 & " was not found in: " _
& newline
msgtext = msgtext & str1
End If
MsgBox msgtext
End Sub
3-164
Version 6.0
See Also
Version 6.0
Left Function on page 3-188, Mid Function on page 3-207, Mid Statement on
page 3-209, Option Compare Statement on page 3-244, Right Function on
page 3-273, Str Function on page 3-331, and StrComp Function on page 3-332
3-165
Int Function
Int(number)
Argument
Description
number
Returns
Usage
For positive numbers, Int removes the fractional part of the expression and returns
the integer part only. For negative numbers, Int returns the largest integer less than
or equal to the expression. For example, Int (6.2) returns 6; Int(-6.2) returns -7.
The return type matches the type of the numeric expression. This includes variant
expressions that will return a result of the same vartype as input, except vartype 8
(string) will be returned as vartype 5 (double) and vartype 0 (empty) will be
returned as vartype 3 (long).
The effect of this function is the same as that of the Fix function, except in the
handling of negative numbers. Thus:
Fix(-8.347) = -8
Int(-8.347) = -9
3-166
Version 6.0
Example
This example uses Int to generate random numbers in the range between the ASCII
values for lowercase a and z (97 and 122). The values are converted to letters and
displayed as a string.
Sub Button_Click
Dim x As Integer, y As Integer
Dim str1 As String, letter As String
Dim randomvalue As Double
Dim upper As Integer, lower As Integer
Dim msgtext, newline
upper = Asc("z")
lower = Asc("a")
newline = Chr(10)
For x = 1 to 26
Randomize
randomvalue = Int(((upper - (lower + 1)) * Rnd)
letter = Chr(randomvalue)
str1 = str1 & letter
'Need to waste time here for fast processors
For y = 1 to 1500
Next y
Next x
msgtext = "The string is:" & newline
msgtext = msgtext & str1
MsgBox msgtext
End Sub
See Also
Version 6.0
+ lower)
Exp Function on page 3-99, Fix Function on page 3-109, Log Function on
page 3-201, Rnd Function on page 3-277, Sgn Function on page 3-301, and Sqr
Function on page 3-327
3-167
InvokeMethod Method
The InvokeMethod method calls a specialized method on an object that is not part
of the objects interface. It may be used with applet, business component, business
object business service, web applet, and application objects. When used with a
business service, it may be used to implement a user-defined method. For details,
see the Siebel Object Interfaces Reference.
3-168
Version 6.0
IPmt Function
This standard VB function returns the interest portion of a payment for a given
period of an annuity.
Syntax
Description
rate
period
nper
pv
The present value of the initial lump sum paid (as in an annuity) or received
(as in a loan)
fv
The future value of the final lump sum required (as in a savings plan) or
paid (which will be 0 in a loan)
due
Returns
Usage
The given interest rate is assumed to be constant over the life of the annuity. If
payments are on a monthly schedule, then rate will be 0.0075 if the annual
percentage rate on the annuity or loan is 9%.
Version 6.0
3-169
Example
This example finds the interest portion of a loan payment amount for payments
made in the last month of the first year. The loan is for $25,000 to be paid back over
5 years at 9.5% interest.
Sub Button_Click
Dim aprate, periods
Dim payperiod
Dim loanpv, due
Dim loanfv, intpaid
Dim msgtext
aprate = .095
payperiod = 12
periods = 120
loanpv = 25000
loanfv = 0
' Assume payments are made at end of month
due = 0
intpaid = IPmt(aprate/12,payperiod,periods, _
loanpv,loanfv,due)
msgtext = "For a loan of $25,000 @ 9.5% for 10 years," _
& Chr(10)
msgtext = msgtext + "the interest paid in month 12 is: "_
& Format(intpaid, "Currency")
MsgBox msgtext
End Sub
See Also
3-170
Version 6.0
IRR Function
This standard VB function returns the internal rate of return for a stream of periodic
cash flows.
Syntax
IRR(valuearray( ), guess)
Argument
Description
valuearray( )
guess
Returns
Usage
Valuearray( ) must have at least one positive value (representing a receipt) and one
negative value (representing a payment). All payments and receipts must be
represented in the exact sequence. The value returned by IRR will vary with the
change in the sequence of cash flows.
In general, a guess value of between 0.1 (10 percent) and 0.15 (15 percent) is a
reasonable estimate.
IRR is an iterative function. It improves a given guess over several iterations until
the result is within 0.00001 percent. If it does not converge to a result within 20
iterations, it signals failure.
Version 6.0
3-171
Example
See Also
3-172
Version 6.0
Is Operator
Compares two object expressions and returns -1 if they refer to the same object, 0
otherwise.
Syntax
objectExpression Is objectExpression
Argument
Description
objectExpression
Returns
Not applicable
Usage
Is can also be used to test if an object variable has been set to Nothing.
Example
For examples of the Is operator, see the CreateObject Function on page 3-50 and the
GetObject Function on page 3-139.
See Also
Version 6.0
3-173
IsDate Function
IsDate(expression)
Argument
Description
expression
Returns
Usage
IsDate returns -1 (TRUE) if the expression is of vartype 7 (date) or a string that can
be interpreted as a date.
Example
This example adds a number to todays date value and checks to see if it is still a
valid date (within the range January 1, 100 AD, through December 31, 9999 AD).
Sub Button_Click
Dim curdatevalue
Dim yrs
Dim msgtext
curdatevalue = DateValue(Date$)
yrs = InputBox("Enter a number of years to add to today's _
date")
yrs = yrs * 365
curdatevalue = curdatevalue + yrs
If IsDate(curdatevalue) = -1 then
MsgBox "The new date is: " & Format(CVDate _
(curdatevalue), "dddddd")
Else
MsgBox "The date is not valid."
End If
End Sub
See Also
3-174
CVDate Function on page 3-59, IsEmpty Function on page 3-175, IsNull Function on
page 3-179, IsNumeric Function on page 3-181, and VarType Function on
page 3-363
Version 6.0
IsEmpty Function
IsEmpty(expression)
Argument
Description
expression
Returns
Usage
IsEmpty returns -1 (TRUE) if the variant is of vartype 0 (empty). Any newly defined
variant defaults to being of Empty type, to signify that it contains no initialized data.
An Empty variant converts to zero when used in a numeric expression, or an empty
string ("") in a string expression.
Example
This example prompts for a series of test scores and uses IsEmpty to determine
whether the maximum allowable limit has been hit. (IsEmpty determines when to
exit the Do...Loop.)
Sub Button_Click
Dim arrayvar(10)
Dim x as Integer
Dim tscore as Single
Dim total as Integer
x = 1
Do
tscore = InputBox("Enter test score #" & x & ":")
arrayvar(x) = tscore
x = x + 1
Loop Until IsEmpty(arrayvar(10)) <> -1
total = x-1
msgtext = "You entered: " & Chr(10)
For x = 1 to total
msgtext = msgtext & Chr(10) & arrayvar(x)
Next x
MsgBox msgtext
End Sub
Version 6.0
3-175
See Also
3-176
IsDate Function on page 3-174, IsNull Function on page 3-179, IsNumeric Function
on page 3-181, and VarType Function on page 3-363
Version 6.0
IsMissing Function
IsMissing(argname)
Argument
Description
argname
Returns
Usage
IsMissing is used in procedures that have optional arguments to find out whether
the arguments value was supplied or not.
Version 6.0
3-177
Example
This example prints a list of letters. The number printed is determined by the user.
If the user wants to print all letters, the Function myfunc is called without any
argument. The function uses IsMissing to determine whether to print all the letters
or just the number specified by the user.
Function myfunc(Optional arg1)
If IsMissing(arg1) = -1 then
arg1 = 26
End If
msgtext = "The letters are: " & Chr$(10)
For x = 1 to arg1
msgtext = msgtext & Chr$(x + 64) & Chr$(10)
Next x
MsgBox msgtext
End Function
Sub Button_Click
Dim arg1
arg1 = InputBox("How many letters do you want to print? _
(0 for all)")
If arg1 = 0 then
myfunc()
Else
myfunc(arg1)
End If
End Sub
See Also
3-178
Version 6.0
IsNull Function
This standard VB function is used to determine whether a variant variable has the
Null value.
Syntax
IsNull(expression)
Argument
Description
expression
Returns
Usage
Null variants have no associated data and serve only to represent invalid or
ambiguous results. Null is not the same as Empty, which indicates that a variant
has not yet been initialized.
Example
This example asks for ten test score values and calculates the average. If any score
is negative, the value is set to Null. Then IsNull is used to reduce the total count of
scores (originally 10) to just those with positive values before calculating the
average.
Sub Button_Click
Dim arrayvar(10)
Dim count as Integer
Dim total as Integer
Dim x as Integer
Dim tscore as Single
count = 10
total = 0
For x = 1 to count
tscore = InputBox("Enter test score #" & x & ":")
If tscore<0 then
arrayvar(x) = Null
Else
arrayvar(x) = tscore
total = total + arrayvar(x)
End If
Next x
Do While x <> 0
x = x - 1
Version 6.0
3-179
If IsNull(arrayvar(x)) = -1 then
count = count-1
End If
Loop
msgtext = "The average (excluding negative values) is: "
msgtext = msgtext & Chr(10) & Format(total/count, "##.##")
MsgBox msgtext
End Sub
See Also
3-180
Version 6.0
IsNumeric Function
IsNumeric(expression)
Argument
Description
expression
Returns
Usage
Example
This example uses IsNumeric to determine whether a user selected an option (1-3)
or typed Q to quit.
Sub Button_Click
Dim answer
answer = InputBox("Enter a choice (1-3) or type Q to _
quit")
If IsNumeric(answer) = -1 then
Select Case answer
Case 1
MsgBox "You chose #1."
Case 2
MsgBox "You chose #2."
Case 3
MsgBox "You chose #3."
End Select
Else
MsgBox "You typed Q."
End If
End Sub
Version 6.0
3-181
See Also
3-182
IsDate Function on page 3-174, IsEmpty Function on page 3-175, IsNull Function on
page 3-179, and VarType Function on page 3-363
Version 6.0
Kill Statement
Kill pathname
Argument
Description
pathname
Returns
Not applicable
Usage
The pathname specification can contain paths and wildcards (? and *). Kill deletes
files only, not directories. Use the RmDir function to delete directories.
Example
This example prompts a user for an account number, opens a file, searches for the
account number, and displays the matching letter for that number. The second
subprogram, CreateFile, creates the file c:\temp001 used by the main
subprogram. After processing is complete, the first subroutine uses Kill to delete the
file.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Global x as Integer
Global y(100) as String
Sub CreateFile
' Put the numbers 1-10 and letters A-J into a file
Dim startletter
Open "c:\temp001" for Output as #1
startletter = 65
For x = 1 to 10
y(x) = Chr(startletter)
startletter = startletter + 1
Next x
For x = 1 to 10
Write #1, x,y(x)
Next x
Close #1
End Sub
Version 6.0
3-183
Sub Button_Click
Dim acctno as Integer
Dim msgtext
Call CreateFile
i: acctno = InputBox("Enter an account number from 1-10:")
If acctno<1 Or acctno>10 then
MsgBox "Invalid account number. Try again."
Goto i:
End if
x = 1
Open "c:\temp001" for Input as #1
Do Until x = acctno
Input #1, x,y(x)
Loop
msgtext = "The letter for account number " & x & " is: _
" & y(x)
Close #1
MsgBox msgtext
kill "c:\temp001"
End Sub
See Also
LastRecord Method
LastRecord moves to the last record in a business component. This method is used
with business component objects. For details, see the Siebel Object Interfaces
Reference.
3-184
Version 6.0
LBound Function
This standard VB function returns the lower bound of the subscript range for an
array.
Syntax
Description
arrayname
dimension
Returns
Usage
The dimensions of an array are numbered starting with 1. If the dimension is not
specified, 1 is the default.
LBound can be used with UBound to determine the length of an array.
Version 6.0
3-185
Example
This example resizes an array if the user enters more data than can fit in the array.
It uses LBound and UBound to determine the existing size of the array and ReDim
to resize it. Option Base sets the default lower bound of the array to 1.
Option Base 1
Sub Button_Click
Dim arrayvar() as Integer
Dim count as Integer
Dim answer as String
Dim x, y as Integer
Dim total
total = 0
x = 1
count = InputBox("How many test scores do you have?")
ReDim arrayvar(count)
start:
Do until x = count + 1
arrayvar(x) = InputBox("Enter test score #" &x & ":")
x = x + 1
Loop
answer = InputBox$("Do you have more scores? (Y/N)")
If answer = "Y" or answer = "y" then
count = InputBox("How many more do you have?")
If count <> 0 then
count = count + (x-1)
ReDim Preserve arrayvar(count)
Goto start
End If
End If
x = LBound(arrayvar,1)
count = UBound(arrayvar,1)
For y = x to count
total = total + arrayvar(y)
Next y
MsgBox "The average of " & count & " scores is: " & _
Int(total/count)
End Sub
See Also
3-186
Dim Statement on page 3-73, Global Statement on page 3-144, Option Base
Statement on page 3-241, ReDim Statement on page 3-263, Static Statement on
page 3-328, and UBound Function on page 3-357
Version 6.0
LCase Function
LCase[$](string)
Argument
Description
string
Returns
Usage
Example
See Also
Version 6.0
3-187
Left Function
This standard VB function returns a string of a specified length copied from the
beginning of another string.
Syntax
Description
string
length
Returns
Usage
If length is greater than the length of string, Left returns the whole string.
Left accepts expressions of type string. Left accepts any type of string, including
numeric values, and will convert the input value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function will typically return a variant of vartype 8 (string).
If the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
This example extracts a users first name from the entire name entered.
Sub Button_Click
Dim username as String
Dim count as Integer
Dim firstname as String
Dim charspace
charspace = Chr(32)
username = InputBox("Enter your first and last name")
count = InStr(username,charspace)
firstname = Left(username,count)
Msgbox "Your first name is: " &firstname
End Sub
3-188
Version 6.0
See Also
Version 6.0
Len Function on page 3-190, LTrim Function on page 3-205, Mid Function on
page 3-207, Mid Statement on page 3-209, Right Function on page 3-273, RTrim
Function on page 3-281, Str Function on page 3-331, StrComp Function on
page 3-332, and Trim Function on page 3-353
3-189
Len Function
Len(string)
Syntax B
Len(varName)
Argument
Description
string
varName
Returns
Usage
If the argument is a string, the number of characters in the string is returned. If the
argument is a variant variable, Len returns the number of bytes required to
represent its value as a string; otherwise, the length of the built-in data type or userdefined type is returned.
If syntax B is used, and varName is a variant containing a NULL, Len will return a
Null variant.
Example
This example returns the length of a name entered by the user (including spaces).
Sub Button_Click
Dim username as String
username = InputBox("Enter your name")
count = Len(username)
Msgbox "The your name has " &count & " characters."
End Sub
See Also
3-190
Version 6.0
Description
variable
expression
Returns
Not applicable
Usage
Version 6.0
3-191
Example
This example uses the Let statement for the variable sum. The subroutine finds an
average of 10 golf scores.
Sub Button_Click
Dim score As Integer
Dim x, sum
Dim msgtext
Let sum = 0
For x = 1 to 10
score = InputBox("Enter your last ten golf scores #" _
& x & ":")
sum = sum + score
Next x
msgtext = "Your average is: " & CInt(sum/(x-1))
MsgBox msgtext
End Sub
See Also
3-192
Version 6.0
Like Operator
Description
string
pattern
Returns
Usage
Matches
A single character
[chars]
[!chars]
[startcharendchar]
[!startcharendchar]
Both ranges and lists can appear within a single set of square brackets. Ranges are
matched according to their ANSI values. In a range, startchar must be less than
endchar.
If either string or pattern is NULL, then the result value is NULL.
The Like operator respects the current setting of Option Compare.
For more information about operators, see Expressions on page 2-18.
Version 6.0
3-193
Example
See Also
3-194
InStr Function on page 3-163, Option Compare Statement on page 3-244, and
StrComp Function on page 3-332
Version 6.0
This standard VB statement reads a line from a sequential file into a string variable.
Syntax A
Syntax B
Description
filenumber
The file number, given in the Open statement, of the open file from which
to read
varName
prompt
Returns
Not applicable
Usage
If it is included, the filenumber is the number used in the Open statement to open
the file. If filenumber is not provided, the line is read from the keyboard.
If prompt is not provided, a question mark (?) is displayed as the prompt.
Line Input is used to read lines of text from a text file in which the data elements
are separated by carriage returns. To read data from a file of comma-separated
values, use Read.
Version 6.0
3-195
Example
This example reads the contents of a sequential file line by line (to a carriage return)
and displays the results. The second subprogram, CreateFile, creates the file
C:\temp001 used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End Sub
Sub Button_Click
Dim testscore as String
Dim x
Dim y
Dim newline
Call CreateFile
Open "c:\temp001" for Input as #1
x = 1
newline = Chr(10)
msgtext = "The contents of c:\temp001 is: " & newline
Do Until x = Lof(1)
Line Input #1, testscore
x = x + 1
y = Seek(1)
If y>Lof(1) then
x = Lof(1)
Else
Seek 1,y
End If
msgtext = msgtext & testscore & newline
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
3-196
Get Statement on page 3-132, Input Function on page 3-156, Input Statement on
page 3-158, InputBox Function on page 3-160, and Open Statement on page 3-238
Version 6.0
Loc Function
This standard VB function returns the current offset within an open file.
Syntax
Loc(filenumber)
Argument
Description
filenumber
The number given in the Open statement, of the open file to query
Returns
For random files, the number of the last record read or written; for files opened in
append, input, or output mode, the current byte offset divided by 128; for files
opened in binary mode, the offset of the last byte read or written.
Example
This example creates a file of account numbers as entered by the user. When the
user finishes, the example displays the offset in the file of the last entry made.
Sub Button_Click
Dim filepos as Integer
Dim acctno() as Integer
Dim x as Integer
x = 0
Open "c:\TEMP001" for Random as #1
Do
x = x + 1
Redim Preserve acctno(x)
acctno(x) = InputBox("Enter account #" & x & " or 0 to _
end:")
If acctno(x) = 0 then
Exit Do
End If
Put #1,, acctno(x)
Loop
filepos = Loc(1)
Close #1
MsgBox "The offset is: " & filepos
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
Eof Function on page 3-86, Lof Function on page 3-200, and Open Statement on
page 3-238
3-197
Lock Statement
Description
filenumber
The file number of the open file as used in the Open statement
start
A long integer representing the number of the first record or byte offset
to lock or unlock
end
A long integer representing the number of the last record or byte offset
to lock or unlock
Returns
Not applicable
Usage
For binary mode, start and end are byte offsets. For random mode, start and end are
record numbers. If start is specified without end, then only the record or byte at start
is locked. If To end is specified without start, then all records or bytes from record
number or offset 1 to end are locked.
For Input, output, and append modes, start and end are ignored and the whole file
is locked.
Lock and Unlock always occur in pairs with identical parameters. All locks on open
files must be removed before closing the file, or unpredictable results will occur.
Example
This example locks a file that is shared by others on a network, if the file is already
in use. The second subprogram, CreateFile, creates the file used by the main
subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
' Put the letters A-J into the file
Dim x as Integer
Open "c:\temp001" for Output as #1
3-198
Version 6.0
For x = 1 to 10
Write #1, Chr(x + 64)
Next x
Close #1
End Sub
Sub Button_Click
Dim btngrp, icongrp
Dim defgrp
Dim answer
Dim noaccess as Integer
Dim msgabort
Dim msgstop as Integer
Dim acctname as String
noaccess = 70
msgstop = 16
Call CreateFile
On Error Resume Next
btngrp = 1
icongrp = 64
defgrp = 0
answer = MsgBox("Open the account file?" & Chr(10), _
btngrp + icongrp + defgrp)
If answer = 1 then
Open "c:\temp001" for Input as #1
If Err = noaccess then
msgabort = MsgBox("File Locked",msgstop,"Aborted")
Else
Lock #1
Line Input #1, acctname
MsgBox "The first account name is: " & acctname
Unlock #1
End If
Close #1
End If
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
3-199
Lof Function
Lof(filenumber)
Argument
Description
filenumber
Returns
Usage
The filenumber is the number used in the Open statement that opened the file.
Example
This example opens a file and prints its contents to the screen.
Sub Button_Click
Dim fname As String,fchar() As String
Dim x As Integer, msgtext As String, newline As String
newline = Chr(10)
fname = InputBox("Enter a filename to print:")
On Error Resume Next
Open fname for Input as #1
If Err <> 0 then
MsgBox "Error opening file. Re-run program."
Exit Sub
End If
msgtext = "The contents of " & fname & " is: " _
& newline & newline
Redim fchar(Lof(1))
For x = 1 to Lof(1)
fchar(x) = Input(1,#1)
msgtext = msgtext & fchar(x)
Next x
MsgBox msgtext
Close #1
End Sub
See Also
3-200
Eof Function on page 3-86, FileLen Function on page 3-107, Loc Function on
page 3-197, and Open Statement on page 3-238
Version 6.0
Log Function
Log(number)
Argument
Description
number
Returns
Usage
Example
This example uses the Log function to determine which number is larger: 999^1000
(999 to the 1000 power) or 1000^999 (1000 to the 999 power). Note that you cannot
use the exponent (^) operator for numbers this large.
Sub Button_Click
Dim x
Dim y
x = 999
y = 1000
a = y * (Log(x))
b = x * (Log(y))
If a>b then
MsgBox "999^1000 is greater than 1000^999"
Else
MsgBox "1000^999 is greater than 999^1000"
End If
End Sub
See Also
Version 6.0
Exp Function on page 3-99, Fix Function on page 3-109, Int Function on page 3-166,
Rnd Function on page 3-277, Sgn Function on page 3-301, and Sqr Function on
page 3-327
3-201
LoginId Method
The LoginId method returns the login id of the user who started the Siebel
applications. It is used with the application object. For details, see the Siebel Object
Interfaces Reference.
LoginName Method
The LoginName method returns the login name of the user who started the Siebel
application (the name typed into the login dialog). It is used with the application
object. For details, see the Siebel Object Interfaces Reference.
3-202
Version 6.0
Lset Statement
Syntax B
Description
string
string-expression
variable1
variable2
Returns
Not applicable
Usage
Version 6.0
3-203
Example
This example puts a users last name into the variable lastname. If the name is
longer than the size of lastname, then the users name is truncated. If you have a
long last name and you get lots of junk mail, youve probably seen how this works.
Sub Button_Click
Dim lastname as String
Dim strlast as String * 8
lastname = InputBox("Enter your last name")
Lset strlast = lastname
msgtext = "Your last name is: " & strlast
MsgBox msgtext
End Sub
See Also
3-204
Version 6.0
LTrim Function
This standard VB function returns a string with all leading spaces removed.
Syntax
LTrim[$](string)
Argument
Description
string
Returns
Usage
LTrim accepts any type of string, including numeric values, and will convert the
input value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function typically returns a variant of vartype 8 (string). If
the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
This example trims the leading spaces from a string padded with spaces on the left.
Sub Button_Click
Dim userinput as String
Dim numsize
Dim str1 as String * 50
Dim strsize
strsize = 50
userinput = InputBox("Enter a string of characters:")
numsize = Len(userinput)
str1 = Space(strsize-numsize) & userinput
' Str1 has a variable number of leading spaces.
MsgBox "The string is: " &str1
str1 = LTrim$(str1)
' Str1 now has no leading spaces.
MsgBox "The string now has no leading spaces: " & str1
End Sub
See Also
Version 6.0
Left Function on page 3-188, Mid Function on page 3-207, Mid Statement on
page 3-209, Right Function on page 3-273, RTrim Function on page 3-281, and Trim
Function on page 3-353
3-205
Me
With Me
.methodname() statement
End With
Syntax B
Me.methodname() statement
Placeholder
Description
methodname
statement
Returns
Not applicable
Usage
Example
See Also
3-206
Version 6.0
Mid Function
Description
string
start
length
Returns
Usage
Mid accepts any type of string, including numeric values, and converts the input
value to a string. If the length argument is omitted or if string is smaller than length,
then Mid returns all characters in string. If start is larger than string, then Mid
returns an empty string ("").
The index of the first character in a string is 1.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function typically returns a variant of vartype 8 (string). If
the value of string is Null, a variant of vartype 1 (Null) is returned. Mid$ requires
the string argument to be of type string or variant. Mid allows the string argument
to be of any data type.
To modify a portion of a string value, see the Mid Statement on page 3-209.
Version 6.0
3-207
Example
This example uses the Mid function to find the last name in a string entered by the
user.
Sub Button_Click
Dim username as String
Dim position as Integer
username = InputBox("Enter your full name:")
Do
position = InStr(username," ")
If position = 0 then
Exit Do
End If
position = position + 1
username = Mid(username,position)
Loop
MsgBox "Your last name is: " & username
End Sub
See Also
3-208
Left Function on page 3-188, Len Function on page 3-190, LTrim Function on
page 3-205, Mid Function on page 3-207, Right Function on page 3-273, RTrim
Function on page 3-281, and Trim Function on page 3-353
Version 6.0
Mid Statement
Mid replaces part (or all) of one string with another, starting at a specified location.
Syntax
Description
stringVar
start
length
string
Returns
Usage
If the length argument is omitted, or if there are fewer characters in string than
specified in length, then Mid replaces all the characters from the start to the end of
the string. If start is larger than the number of characters in the indicated stringVar,
then Mid appends string to stringVar.
If length is greater than the length of string, then length is set to the length of string.
If start is greater than the number of characters in stringVar, an illegal function call
error will occur at runtime. If length plus start is greater than the length of stringVar,
then only the characters up to the end of stringVar are replaced.
Mid never changes the number of characters in stringVar.
The index of the first character in a string is 1.
Version 6.0
3-209
Example
This example uses the Mid statement to replace the last name in a user-entered
string with asterisks (*).
Sub Button_Click
Dim username as String
Dim position as Integer
Dim count as Integer
Dim uname as String
Dim replacement as String
username = InputBox("Enter your full name:")
uname = username
replacement = "*"
Do
position = InStr(username," ")
If position = 0 then
Exit Do
End If
username = Mid(username,position + 1)
count = count + position
Loop
For x = 1 to Len(username)
count = count + 1
Mid(uname,count) = replacement
Next x
MsgBox "Your name now is: " & uname
End Sub
See Also
3-210
LCase Function on page 3-187, Left Function on page 3-188, Len Function on
page 3-190, LTrim Function on page 3-205, Mid Statement on page 3-209, Right
Function on page 3-273, RTrim Function on page 3-281, and Trim Function on
page 3-353
Version 6.0
Minute Function
Minute(time)
Argument
Description
time
Returns
Usage
Time can be of any type, including strings, and Minute will attempt to convert the
input value to a date-time value.
In order for Minute to function without an error, the values passed to it must be in
some form that can be interpreted as a time or date-time value. Thus, 13:26, or
1:45:12 PM will return valid results, but 1326 will return a 0.
The return value is a variant of vartype 2 (integer). If the value of time is null, a
variant of vartype 1 (Null) is returned.
Version 6.0
3-211
Example
This example extracts just the time (hour, minute, and second) from a files last
modification date and time.
Sub Button_Click
Dim filename as String
Dim ftime
Dim hr, min
Dim sec
Dim msgtext as String
i: msgtext = "Enter a filename:"
filename = InputBox(msgtext)
If filename = "" then
Exit Sub
End If
On Error Resume Next
ftime = FileDateTime(filename)
If Err <> 0 then
MsgBox "Error in file name. Try again."
Goto i:
End If
hr = Hour(ftime)
min = Minute(ftime)
sec = Second(ftime)
Msgbox "The file's time is: " & hr &":" &min &":" &sec
End Sub
See Also
3-212
Version 6.0
MkDir Statement
MkDir [drive:][\directory\]directory
Argument
Description
drive:
\directory\
directory
Returns
Not applicable
Usage
The drive: argument is optional. If drive: is omitted, MkDir creates the new directory
on the current drive. If the drive: argument is used, it must include the colon.
Example
This example makes a new temporary directory in C:\ and then deletes it.
Sub Button_Click
Dim path as String
On Error Resume Next
path = CurDir(C)
If path <> "C:\" then
ChDir "C:\"
End If
MkDir "C:\TEMP01"
If Err = 75 then
MsgBox "Directory already exists"
Else
MsgBox "Directory C:\TEMP01 created"
MsgBox "Now removing directory"
RmDir "C:\TEMP01"
End If
End Sub
See Also
Version 6.0
ChDir Statement on page 3-35, ChDrive Statement on page 3-37, CurDir Function
on page 3-56, Dir Function on page 3-79, and RmDir Statement on page 3-275
Siebel VB Language Reference
3-213
Month Function
This standard VB function returns an integer for the month component (112) of a
date-time value.
Syntax
Month(date)
Argument
Description
date
Returns
Usage
Date can be of any type, including string, and Month will attempt to convert the
input value to a date-time value.
In order for Month to function without an error, the values passed to it must be in
some form that can be interpreted as a time or date-time value. Thus, 11/20, or 1120-2001 will return valid results, but 1120 will return a 0.
The return value is a variant of vartype 2 (integer). If the value of date is null, a
variant of vartype 1 (null) is returned.
Example
This example finds the month (112) and day (1-31) values for this Thursday.
Sub Button_Click
Dim x As Integer, Today As Variant
Dim msgtext
Today = DateValue(Now)
Let x = 0
Do While Weekday(Today + x) <> 5
x = x + 1
Loop
msgtext = "This Thursday is: " & Month(Today + x) &"/" _
& Day(Today + x)
MsgBox msgtext
End Sub
3-214
Version 6.0
See Also
Version 6.0
3-215
Msgbox Function
Syntax B
(Statement)
Returns
3-216
Argument
Description
prompt
buttons
title
If used as a function, a value indicating the button pressed. The return values for
the Msgbox function are:
Value
Button Pressed
OK
Cancel
Abort
Retry
Ignore
Yes
No
Version 6.0
Usage
Use the MsgBox function when some action must be taken in the program based on
the users response. Otherwise, use the MsgBox statement.
Prompt must be no longer than 1,024 characters. A message string greater than 255
characters without intervening spaces will be truncated after the 255th character.
Buttons is the sum of three values, one from each of the following groups:
Value
Description
Group 1:
OK only
Buttons
OK, Cancel
Yes, No
Retry, Cancel
Group 2:
16
Icons
32
Warning Query ( ? )
48
Warning Message ( ! )
64
Informational Message ( i )
Group 3:
First button
Default
Button
256
Second button
512
Third button
Version 6.0
3-217
Example
See Also
3-218
Version 6.0
MsgBox Method
The MsgBox method displays a message box and is similar to the Siebel VB
function. For compatibility with Siebel VB, MsgBox can also be accessed as a global
method. Unlike the standard VB function, this method is invoked upon an object
instance, specifically, an instance of the application. For details, see the Siebel
Object Interfaces Reference.
Name Method
The Name method returns the name of the object with which it is used. It can be
used with applet, business component, business object, control, and application
objects. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-219
Name Statement
This standard VB statement renames a file or copies a file from one directory to
another.
Syntax
Description
path1\
A string expression containing the path to the current location of the file
(must be entered if the file is not in the current directory of the current
drive)
oldfilename
path2\
newfilename
Returns
Not applicable
Usage
A file must be closed in order to be renamed. If the file oldfilename is open or if the
file newfilename already exists, Siebel VB generates an error message.
If this statement is used within the Siebel application, and no path2\ is specified, a
copy of the original file will appear in the c:\siebel\bin directory under the
new name.
3-220
Version 6.0
Example
See Also
Version 6.0
3-221
New Operator
The New operator allocates and initializes a new COM object of the named class.
Syntax
Description
objectVar
className
Returns
Not applicable
Usage
In the Dim statement, New marks objectVar so that a new object will be allocated
and initialized when objectVar is first used. If objectVar is not referenced, then no
new object will be allocated.
NOTE: An object variable that was declared with New will allocate a second object
See Also
3-222
Version 6.0
NewPropertySet Method
The NewPropertySet method constructs a new property set object. For details, see
the Siebel Object Interfaces Reference.
NewRecord Method
NewRecord adds a new record (row) to a Siebel business component. This method
is used with business component objects. For details, see the Siebel Object Interfaces
Reference.
NextRecord Method
NextRecord moves the current record to the next record in a Siebel business
component, invoking any associated Basic events. This method is used with
business component objects. For details, see the Siebel Object Interfaces Reference.
NextSelected Method
NextSelected moves the focus to the next record of the current multiple selection in
a Siebel business component. This method is used with business component
objects. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-223
Nothing Function
Description
objectName
Returns
Not applicable
Usage
Nothing is the value object variables have when they do not refer to an object, either
because they have not been initialized yet or because they were explicitly set to
Nothing. For example:
If Not objectVar Is Nothing then
objectVar.Close
Set objectVar = Nothing
End If
Use the Nothing function to remove an object that you have instantiated from
memory.
3-224
Version 6.0
Example
This example adds an activity record indicating that a contact has been added when
a new contact is added in the Siebel application. It presumes that Contact is the
parent business component and instantiates the Activity business component,
destroying it using the Nothing statement after the job is complete. For other
examples of the Nothing function, see the CreateObject Function on page 3-50 and
the GetObject Function on page 3-139.
Sub BusComp_WriteRecord
Dim oBCact as BusComp
Set oBCact = theApplication.ActiveBusObject.GetBusComp("Action")
With oBCact
.NewRecord NewAfter
.SetFieldValue "Type", "Event"
.SetFieldValue "Description", "ADDED THRU SVB"
.SetFieldValue "Done", Format(Now(),"mm/dd/yyyy hh:mm:ss")
.SetFieldValue "Status", "Done"
.WriteRecord
End With
theApplication.MsgBox("Activity Added")
MsgBox("Activity Added")
set oBCact = Nothing
End Sub
See Also
Version 6.0
Is Operator on page 3-173, New Operator on page 3-222, and Siebel Object Interfaces
Reference
3-225
Now Function
Now()
Argument
Description
Not applicable
Returns
The current date and time as indicated by the computers system clock.
Usage
The Now function returns a variant of vartype 7 (date) that represents the current
date and time according to the setting of the computers system date and time. Use
the Format function to specify the format in which the date and time should appear.
Example
This example finds the month (112) and day (131) values for this Thursday. For
another example, see the Format Function on page 3-114.
Sub Button_Click
Dim x As Integer, today As Variant
Dim msgtext As String
Today = DateValue(Now)
Let x = 0
Do While Weekday(Today + x) <> 5
x = x + 1
Loop
msgtext = "This Thursday is: " & Month(Today + x) & "/" & _
Day(Today + x)
MsgBox msgtext
End Sub
See Also
3-226
Date Function on page 3-61, Date Statement on page 3-62, Day Function on
page 3-67, Hour Function on page 3-152, Minute Function on page 3-211, Second
Function on page 3-282, Time Function on page 3-343, Time Statement on
page 3-345, WebApplet_InvokeMethod Event on page 3-366, and Year Function on
page 3-376
Version 6.0
NPV Function
This standard VB function returns the net present value of an investment based on
a stream of periodic cash flows and a constant interest rate.
Syntax
NPV(rate, valuearray( ))
Argument
Description
rate
valuearray( )
Returns
The net present value of cash flows in valuarray( ) based on the rate.
Usage
Valuearray( ) must have at least one positive value (representing a receipt) and one
negative value (representing a payment). All payments and receipts must be
represented in the exact sequence. The value returned by NPV will vary with the
change in the sequence of cash flows.
If the discount rate is 12% per period, rate is the decimal equivalent, that is, 0.12.
NPV uses future cash flows as the basis for the net present value calculation. If the
first cash flow occurs at the beginning of the first period, its value should be added
to the result returned by NPV and must not be included in valuearray().
Version 6.0
3-227
Example
This example finds the net present value of an investment, given a range of cash
flows by the user.
Sub Button_Click
Dim aprate as Single
Dim varray() as Double
Dim cflowper as Integer
Dim x as Integer
Dim netpv as Double
cflowper = InputBox("Enter number of cash flow periods")
ReDim varray(cflowper)
For x = 1 to cflowper
varray(x) = InputBox("Enter cash flow amount for period " & x
Next x
aprate = InputBox("Enter discount rate: ")
If aprate>1 then
aprate = aprate/100
End If
netpv = NPV(aprate,varray())
MsgBox "The net present value is: " & Format(netpv, "Currency")
End Sub
See Also
3-228
Version 6.0
Null Function
Null
Argument
Description
Not applicable
Returns
Usage
Null is used to set a variant variable to the Null value explicitly, as follows:
variableName = Null
Note that variants are initialized by Basic to the empty value, which is different from
the Null value.
Example
This example asks for ten test score values and calculates the average. If any score
is negative, the value is set to Null. Then IsNull is used to reduce the total count of
scores (originally 10) to just those with positive values before calculating the
average.
Sub Button_Click
Dim arrayvar(10)
Dim count as Integer
Dim total as Integer
Dim x as Integer
Dim tscore as Single
count = 10
total = 0
For x = 1 to count
tscore = InputBox("Enter test score #" & x & ":")
If tscore < 0 then
arrayvar(x) = Null
Else
arrayvar(x) = tscore
total = total + arrayvar(x)
End If
Next x
Version 6.0
3-229
Do While x <> 0
x = x - 1
If IsNull(arrayvar(x)) = -1 then
count = count - 1
End If
Loop
msgtext = The average (excluding negative values) is: "
msgtext = msgtext & Chr(10) & Format (total/count, "##.##")
MsgBox msgtext
End Sub
See Also
3-230
IsEmpty Function on page 3-175, IsNull Function on page 3-179, and VarType
Function on page 3-363
Version 6.0
Object Class
Description
variableName
Returns
Not applicable
Usage
To create a new object, first dimension a variable, using the Dim statement, then set
the variable to the return value of CreateObject or GetObject, as follows:
Dim COM As Object
Set COM = CreateObject("spoly.cpoly")
To refer to a method or property of the newly created object, use the syntax
objectvar.property or objectvar.method, as follows:
COM.reset
Version 6.0
3-231
Example
This example uses the special Siebel object class BusComp to declare the variables
used for accessing the Account Contacts view within the Siebel application.
Sub Button1_Click
Dim i as integer
Dim icount as integer
Dim oBC as BusComp
'
'
'
'
See Also
3-232
Version 6.0
Oct Function
Oct[$](number)
Argument
Description
number
Returns
Usage
If the numeric expression has a data type of integer, the string contains up to six
octal digits; otherwise, the expression will be converted to a data type of long, and
the string can contain up to 11 octal digits.
The dollar sign ($) in the function name is optional. If it is included, the return data
type is string. Otherwise the function returns a variant of vartype 8 (string).
NOTE: To represent an octal number directly, precede the octal value with &O. For
Example
This example prints the octal values for the numbers from 1 to 15.
Sub Button_Click
Dim x As Integer, y As Integer
Dim msgtext As String
Dim nofspaces As Integer
msgtext = "Octal numbers from 1 to 15:" & Chr(10)
For x = 1 to 15
nofspaces = 10
y = Oct(x)
If Len(x) = 2 then
nofspaces = nofspaces - 2
End If
msgtext = msgtext & Chr(10) & x & Space(nofspaces) & y
Next x
MsgBox msgtext
End Sub
See Also
Version 6.0
3-233
On...GoTo Statement
Description
number
Returns
Not applicable
Usage
Example
See Also
3-234
GoTo Statement on page 3-148 and Select Case Statement on page 3-288
Version 6.0
On Error Statement
Returns
Not applicable
Usage
On Error is used to provide routines to handle specific errors. On Error can also be
used to disable an error-handling routine. Unless an On Error statement is used, any
run-time error will be fatal; that is, Siebel VB will terminate the execution of the
program.
An On Error statement includes one of the following parts:
Part
Definition
GoTo label
Resume Next
GoTo 0
Version 6.0
3-235
NOTE: Because Siebel VB searches in the caller for an error handler, any additional
This example prompts the user for a drive and directory name and uses On Error to
trap invalid entries.
Sub Button_Click
Dim userdrive, userdir, msgtext
in1:
userdrive = InputBox("Enter drive:",,"C:")
On Error Resume Next
ChDrive userdrive
If Err = 68 then
MsgBox "Invalid Drive. Try again."
Goto in1
End If
in2:
On Error Goto Errhdlr1
userdir = InputBox("Enter directory path:")
ChDir userdrive & userdir
Msgbox "New default directory is: " & userdrive & _
userdir
Exit Sub
Errhdlr1:
Select Case Err
Case 75
msgtext = "Path is invalid."
Case 76
msgtext = "Path not found."
Case 70
msgtext = "Permission denied."
Case Else
msgtext = "Error " & Err & ": " & Error$ & "occurred."
End Select
MsgBox msgtext & " Try again."
Resume in2
End Sub
3-236
Version 6.0
See Also
Version 6.0
Erl Function on page 3-90, Err Function on page 3-91, Err Statement on page 3-92,
Error Function on page 3-94, Error Statement on page 3-96, and Resume Statement
on page 3-271
3-237
Open Statement
Open filename [For mode] [Access access] [lock] As [#]filenumber [Len = reclen]
Argument
Description
filename
mode
access
lock
filenumber
reclen
Returns
Usage
The following keywords are used for mode, access, and lock:
Keyword
Consequences
Mode Keywords
3-238
Input
Output
Append
Random
Binary
Version 6.0
Keyword
Consequences
Access Keywords
Read
Write
Read Write
Lock Keywords
Shared
Lock Read
Lock Write
A file must be opened before any input/output operation can be performed on it.
If filename does not exist, it is created when opened in append, binary, output, or
random modes.
If mode is not specified, it defaults to random.
If access is not specified for random or binary modes, access is attempted in the
following order: Read Write, Write, Read.
If lock is not specified, filename can be opened by other processes that do not
specify a lock, although that process cannot perform any file operations on the file
while the original process still has the file open.
Use the FreeFile function to find the next available value for filenumber.
The reclen parameter is ignored for Input, Output, and Append modes.
Version 6.0
3-239
Example
This example opens a file for random access, gets the contents of the file, and closes
the file again. The second subprogram, CreateFile, creates the file c:\temp001
used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
' Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End Sub
Sub Button_Click
Dim acctno as String * 3
Dim recno as Long
Dim msgtext as String
Call CreateFile
recno = 1
newline = Chr(10)
Open "c:\temp001" For Random As #1 Len = 3
msgtext = "The account numbers are:" & newline
Do Until recno = 11
Get #1,recno,acctno
msgtext = msgtext & acctno
recno = recno + 1
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
3-240
Version 6.0
This standard VB statement specifies the default lower bound to use for array
subscripts.
Syntax
Description
lowerBound
Returns
Not applicable
Usage
If no Option Base statement is specified, the default lower bound for array
subscripts will be 0.
Version 6.0
3-241
The Option Base statement is not allowed inside a procedure and must precede any
use of arrays in the module. Only one Option Base statement is allowed per module.
It must be placed in the (general) (declarations) section in the Siebel VB Editor, as
shown in Figure 3-4.
Figure 3-4.
3-242
Version 6.0
Example
This example resizes an array if the user enters more data than can fit in the array.
It uses LBound and UBound to determine the existing size of the array and ReDim
to resize it. Option Base sets the default lower bound of the array to 1.
Option Base 1
Sub Button_Click
Dim arrayvar() as Integer
Dim count as Integer
Dim answer as String
Dim x, y as Integer
Dim total
total = 0
x = 1
count = InputBox("How many test scores do you have?")
ReDim arrayvar(count)
start:
Do until x = count + 1
arrayvar(x) = InputBox("Enter test score #" &x & ":")
x = x + 1
Loop
answer = InputBox$("Do you have more scores? (Y/N)")
If answer = "Y" or answer = "y" then
count = InputBox("How many more do you have?")
If count <> 0 then
count = count + (x - 1)
ReDim Preserve arrayvar(count)
Goto start
End If
End If
x = LBound(arrayvar,1)
count = UBound(arrayvar,1)
For y = x to count
total = total + arrayvar(y)
Next y
MsgBox "The average of " & count & " scores is: "& Int(total/count)
End Sub
See Also
Version 6.0
Dim Statement on page 3-73, Global Statement on page 3-144, LBound Function on
page 3-185, ReDim Statement on page 3-263, and Static Statement on page 3-328
3-243
This standard VB statement specifies the default method for string comparisons:
either case-sensitive or case-insensitive.
Syntax
Description
Not applicable
Returns
Not applicable
Usage
3-244
Version 6.0
Example
This example compares two strings: JANE SMITH and jane smith. When Option
Compare is Text, the strings are considered the same. If Option Compare is Binary,
they will not be the same. Binary is the default. To see the difference, run the
example once, then run it again, commenting out the Option Compare statement.
Option Compare Text
Sub Button_Click
Dim strg1 as String
Dim strg2 as String
Dim retvalue as Integer
strg1 = "JANE SMITH"
strg2 = "jane smith"
i:
retvalue = StrComp(strg1,strg2)
If retvalue = 0 then
MsgBox "The strings are identical"
Else
MsgBox "The strings are not identical"
Exit Sub
End If
End Sub
See Also
Version 6.0
3-245
Option Explicit
Argument
Description
Not applicable
Returns
Not applicable
Usage
By default, Basic automatically declares any variables that do not appear in a Dim,
Global, Redim, or Static statement. Option Explicit causes such variables to produce
a Variable Not Declared error.
Using the Option Explicit statement makes debugging code easier, because it forces
you to declare all variables before use. It is considered good programming practice
to declare all variables at the beginning of the unit within which they have scope
(that is, at the beginning of the project, module, or procedure). Declaring variables
in this manner simplifies finding their definitions when reading through code.
The Option Explicit statement must be placed in the (general) (declarations) section
in the Siebel VB Editor, as shown in Figure 3-4 on page 3-242.
Example
This example specifies that all variables must be explicitly declared, thus preventing
any mistyped variable names.
Option Explicit
Sub Button_Click
Dim counter As Integer
Dim fixedstring As String * 25
Dim varstring As String
'...(code here)...
End Sub
3-246
Version 6.0
See Also
Version 6.0
Const Statement on page 3-47, Deftype Statement on page 3-71, Dim Statement on
page 3-73, Function...End Function Statement on page 3-127, Global Statement on
page 3-144, ReDim Statement on page 3-263, Static Statement on page 3-328, and
Sub...End Sub Statement on page 3-336
3-247
ParentBusComp Method
ParentBusComp returns the parent (master) Siebel business component given the
child (detail) business component of a Link. This method is used with business
component objects. For details, see the Siebel Object Interfaces Reference.
Pick Method
The Pick method picks the currently selected record in a picklist business
component (see GetPicklistBusComp) into the appropriate Fields of the parent
business component. This method is used with business component objects. For
details, see the Siebel Object Interfaces Reference.
3-248
Version 6.0
Pmt Function
Description
rate
nper
pv
The present value of the initial lump sum amount paid (as with an annuity)
or received (as with a loan)
fv
The future value of the final lump sum amount required (as with a savings
plan) or paid (0 as with a loan)
due
Returns
Usage
Rate is assumed to be constant over the life of the loan or annuity. If payments are
on a monthly schedule, then rate will be 0.0075 if the annual percentage rate on the
annuity or loan is 9%.
Version 6.0
3-249
Example
See Also
3-250
Version 6.0
PositionId Method
The PositionId property returns the position id (ROW_ID from S_POSTN) of the
users current position. This is set by default when the Siebel application is started
and may be changed (via Edit: Change Position) if the user belongs to more than
one position. This method is used with the application object. For details, see the
Siebel Object Interfaces Reference.
PositionName Method
The PositionName property returns the position name of the users current position.
This is set by default when the Siebel application is started and may be changed
(via Edit: Change Position) if the user belongs to more than one position. This
method is used with the application object. For details, see the Siebel Object
Interfaces Reference.
PostChanges Method
PostChanges posts changes that are made in an applet. This method is used with
applet objects. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-251
PPmt Function
This standard VB function returns the principal portion of the payment for a given
period of an annuity.
Syntax
Description
rate
per
nper
pv
The present value of the initial lump sum amount paid (as with an annuity)
or received (as with a loan)
fv
The future value of the final lump sum amount required (as with a savings
plan) or paid (0 as with a loan)
due
Returns
Usage
Rate is assumed to be constant over the life of the loan or annuity. If payments are
on a monthly schedule, then rate will be 0.0075 if the annual percentage rate on the
annuity or loan is 9%.
3-252
Version 6.0
Example
This example finds the principal portion of a loan payment amount for payments
made in the last month of the first year. The loan is for $25,000 to be paid back over
5 years at 9.5% interest.
Sub Button_Click
Dim aprate, periods
Dim payperiod
Dim loanpv, due
Dim loanfv, principal
Dim msgtext
aprate = 9.5/100
payperiod = 12
periods = 120
loanpv = 25000
loanfv = 0
' Assume payments are made at end of month
due = 0
principal = PPmt(aprate/12,payperiod,periods, _
-loanpv,loanfv,due)
msgtext = "Given a loan of $25,000 @ 9.5% for 10 years,"
msgtext = msgtext & Chr(10) & "the principal paid in month 12 is: "
MsgBox msgtext & Format(principal, "Currency")
End Sub
See Also
PreviousRecord Method
Version 6.0
3-253
Print Statement
Description
filenumber
expressionList
Returns
Not applicable
Usage
The Print statement outputs data to the specified filenumber. Filenumber is the
number assigned to the file when it was opened. See Open Statement on
page 3-238 for more information. If this argument is omitted, the Print statement
outputs data to the current window.
If the expressionList is omitted, a blank line is written to the file or the window.
The values in expressionList may be separated by either a semi-colon or a comma.
A semi-colon indicates that the next value should appear immediately after the
preceding one without intervening white space. A comma indicates that the next
value should be positioned at the next print zone. Print zones begin every 14 spaces.
The optional [{;|, }] argument at the end of the Print statement determines where
output for the next Print statement to the same output file should begin. A semicolon will place output immediately after the output from this Print statement on
the current line; a comma will start output at the next print zone on the current line.
If neither separator is specified, a CR-LF pair will be generated and the next Print
statement will print to the next line.
The Spc and Tab functions can be used inside a Print statement to insert a given
number of spaces and to move the print position to a desired column, respectively.
The Print statement supports only elementary Basic data types. See the Input
Function on page 3-156 for more information on parsing this statement.
3-254
Version 6.0
Example
This example prints the octal values for the numbers from 1 to 25.
Sub Button_Click
Dim x as Integer
Dim y
For x = 1 to 25
y = Oct$(x)
Print x Tab(10) y
Next x
End Sub
See Also
Open Statement on page 3-238, Spc Function on page 3-306, Tab Function on
page 3-339, and Write Statement on page 3-374
PropertyExists Method
Version 6.0
3-255
Put Statement
Description
filenumber
The file number used in the Open statement to open the file
recnumber
An expression of type long containing the record number or the byte offset
at which to start writing
varName
Returns
Not applicable
Usage
Filenumber is the number assigned to the file when it was opened. See the Open
Statement on page 3-238 for more information.
Recnumber is in the range 1 to 2,147,483,647. If recnumber is omitted, the next
record or byte is written.
NOTE: The commas before and after recnumber are required, even if no recnumber
is specified.
VarName can be any variable type except object, application data type, or array
variables (single array elements can be used).
For random mode, the following conditions apply:
Blocks of data are written to the file in chunks whose size is equal to the size
specified in the Len clause of the Open statement. If the size of varName is
smaller than the record length, the record is padded to the correct record size. If
the size of the variable is larger than the record length, an error occurs.
For variable length string variables, Put writes two bytes of data that indicate the
length of the string, then writes the string data.
3-256
Version 6.0
For variant variables, Put writes two bytes of data that indicate the type of the
variant, then it writes the body of the variant into the variable. Note that variants
containing strings contain two bytes of type information, followed by two bytes
of length, followed by the body of the string.
User defined types are written as if each member were written separately, except
no padding occurs between elements.
Files opened in binary mode behave similarly to those opened in random mode
except:
This example opens a file for Random access, puts the values 1 through 10 in it,
prints the contents, and closes the file again.
Sub Button_Click
' Put the numbers 1-10 into a file
Dim x As Integer, y As Integer
Open "C:\TEMP001" as #1
For x = 1 to 10
Put #1,x, x
Next x
msgtext = "The contents of the file is:" & Chr(10)
For x = 1 to 10
Get #1,x, y
msgtext = msgtext & y & Chr(10)
Next x
Close #1
MsgBox msgtext
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
Close Statement on page 3-45, Get Statement on page 3-132, Open Statement on
page 3-238, and Write Statement on page 3-374
3-257
PV Function
This standard VB function returns the present value of a constant periodic stream
of cash flows as in an annuity or a loan.
Syntax
Description
rate
nper
pmt
fv
The future value of the final lump sum amount required (as with a savings
plan) or paid (0 as with a loan)
due
Returns
Usage
Rate is assumed constant over the life of the annuity. If payments are on a monthly
schedule, then rate will be 0.0075 if the annual percentage rate on the annuity or
loan is 9%.
3-258
Version 6.0
Example
This example finds the present value of a 10-year $25,000 annuity that will pay
$1,000 a year at 9.5%.
Sub Button_Click
Dim aprate As Integer, periods As Integer
Dim payment As Double, annuityfv As Double
Dim due As Integer, presentvalue As Double
Dim msgtext
aprate = 9.5
periods = 120
payment = 1000
annuityfv = 25000
' Assume payments are made at end of month
due = 0
presentvalue = PV(aprate/12,periods,-payment, annuityfv,due)
msgtext = "The present value for a 10-year $25,000 annuity @ 9.5%"
msgtext = msgtext & " with a periodic payment of $1,000 is: "
msgtext = msgtext & Format(presentvalue, "Currency")
MsgBox msgtext
End Sub
See Also
Version 6.0
3-259
Randomize Statement
Randomize [number]
Argument
Description
number
Returns
Not applicable
Usage
If no number argument is given, Siebel VB uses the Timer function to initialize the
random number generator.
Example
See Also
3-260
+ lower)
Version 6.0
Rate Function
This standard VB function returns the interest rate per period for an annuity or a
loan.
Syntax
Description
nper
pmt
pv
The present value of the initial lump sum amount paid (as with an
annuity) or received (as with a loan)
fv
The future value of the final lump sum amount required (as with a savings
plan) or paid (0 as with a loan)
due
guess
Returns
Usage
In general, a guess of between 0.1 (10 percent) and 0.15 (15 percent) would be a
reasonable value for guess.
Rate is an iterative function: It improves the given value of guess over several
iterations until the result is within 0.00001 percent. If it does not converge to a result
within 20 iterations, it signals failure.
Version 6.0
3-261
Example
This example finds the interest rate on a 10-year $25,000 annuity that pays $100 per
month.
Sub Button_Click
Dim aprate
Dim periods
Dim payment, annuitypv
Dim annuityfv, due
Dim guess
Dim msgtext as String
periods = 120
payment = 100
annuitypv = 0
annuityfv = 25000
guess = .1
' Assume payments are made at end of month
due = 0
aprate = Rate(periods,-payment,annuitypv,annuityfv, _
due, guess)
aprate = (aprate * 12)
msgtext = "The percentage rate for a 10-year $25,000 _
annuity"
msgtext = msgtext & "that pays $100/month has "
msgtext = msgtext & "a rate of: " & Format(aprate, _
"Percent")
MsgBox msgtext
End Sub
See Also
3-262
Version 6.0
ReDim Statement
This standard VB statement changes the upper and lower bounds of a dynamic
arrays dimensions.
Syntax
Description
arrayName
lower
upper
type
Returns
Not applicable
Usage
ReDim reallocates memory for the dynamic array to support the specified
dimensions, and can optionally re-initialize the array elements. ReDim cannot be
used at the module level; it must be used inside of a procedure.
The Preserve option is used to change the last dimension in the array while
maintaining its contents. If Preserve is not specified, the contents of the array are
re-initialized. Numbers will be set to zero (0). Strings and variants will be set to
empty ("").
If lower is not specified, 0 is used as the default. The Option Base statement can be
used to change the default.
A dynamic array is normally created by using Dim to declare an array without a
specified size. The maximum number of dimensions for a dynamic array created in
this fashion is 8. If you need more than 8 dimensions, you can use the ReDim
statement inside of a procedure to declare an array that has not previously been
declared using Dim or Global. In this case, the maximum number of dimensions
allowed is 60.
The available data types for arrays are numbers, strings, variants, records, and
objects. Arrays of arrays, dialog box records, and objects are not supported.
Version 6.0
3-263
If the As clause is not used, the type of the variable can be specified by using a type
character as a suffix to the name. The two different type-specification methods can
be intermixed in a single ReDim statement (although not on the same variable).
The ReDim statement cannot be used to change the number of dimensions of a
dynamic array once the array has been given dimensions. It can change only the
upper and lower bounds of the dimensions of the array. The LBound and UBound
functions can be used to query the current bounds of an array variables
dimensions.
Care should be taken to avoid redimensioning an array in a procedure that has
received a reference to an element in the array in an argument; the result is
unpredictable.
Example
This example finds the net present value for a series of cash flows. The array
variable that holds the cash flow amounts is initially a dynamic array that is
redimensioned after the user enters the number of cash flow periods.
Sub Button_Click
Dim aprate as Single
Dim varray() as Double
Dim cflowper as Integer
Dim x as Integer
Dim netpv as Double
Dim msgtext as string
cflowper = InputBox("Enter number of cash flow periods:")
ReDim varray(cflowper)
msgtext = "Enter cash flow amount for period #" & x & ":"
For x = 1 to cflowper
varray(x) = InputBox(msgtxt)
Next x
msgtext = "Enter discount rate:"
aprate = InputBox (msgtext)
If aprate > 1 then
aprate = aprate / 100
End If
netpv = NPV(aprate,varray())
msgtext = "The Net Present Value is: " & Format(netpv, "Currency")
MsgBox msgtext
End Sub
See Also
3-264
Dim Statement on page 3-73, Global Statement on page 3-144, Option Base
Statement on page 3-241, and Static Statement on page 3-328
Version 6.0
RefineQuery Method
This method refines a query on a Siebel business component after the query has
been executed. This method is used with business component objects. For details,
see the Siebel Object Interfaces Reference.
Version 6.0
3-265
Rem Statement
Rem comment
Returns
Not applicable
Usage
Everything from Rem to the end of the line is ignored when the program is executed.
The single quote (') can also be used to initiate a comment.
Example
This program is attached to a button on the Account Form applet that counts the
number of corresponding child Contact records.
Sub Button1_Click
Dim i as Integer
Dim icount as Integer
Dim oBC as BusComp
Rem
Rem
Rem
Rem
3-266
Version 6.0
else
icount = 0
Rem This is a sample of using a while statement to loop.
Rem NextRecord will return 1 if it succesfully
Rem moved to the next record in the BC
While i = 1
icount = icount + 1
i = oBC.NextRecordRem Returns 1 if successful
wend
MsgBox("Total Records = " & str(icount))
oBC.FirstRecord
end if
End Sub
Version 6.0
3-267
RemoveChild() Method
RemoveChild removes a child property set from a parent property set. For details,
see the Siebel Object Interfaces Reference.
RemoveProperty Method
Reset Method
This method removes all properties and child property sets from a property set. For
details, see the Siebel Object Interfaces Reference.
3-268
Version 6.0
Reset Statement
This standard VB statement closes all open disk files and writes to disk any data in
the operating system buffers.
Syntax
Reset
Argument
Description
Not applicable
Returns
Not applicable
Example
This example creates a file, puts the numbers 1 through 10 in it, then attempts to
get past the end of the file. The On Error statement traps the error and execution
goes to the Debugger code, which uses Reset to close the file before exiting.
Sub Button_Click
' Put the numbers 1-10 into a file
Dim x as Integer
Dim y as Integer
On Error Goto Debugger
Open "c:\temp001" as #1 Len = 2
For x = 1 to 10
Put #1,x, x
Next x
Close #1
msgtext = "The contents of the file is:" & Chr(10)
Open "C:\TEMP001" as #1 Len = 2
For x = 1 to 10
Get #1,x, y
msgtext = msgtext & Chr(10) & y
Next x
MsgBox msgtext
done:
Close #1
Kill "c:\temp001"
Exit Sub
Version 6.0
3-269
Debugger:
MsgBox "Error " & Err & " occurred. Closing open file."
Reset
Resume done
End Sub
See Also
3-270
Version 6.0
Resume Statement
Resume Next
Syntax B
Resume label
Syntax C
Resume [0]
Argument
Description
label
The label that identifies the program line to go to after handling an error
Returns
Not applicable
Usage
When the Resume Next statement is used, control is passed to the statement that
immediately follows the statement in which the error occurred.
When the Resume [0] statement is used, control is passed to the statement in which
the error occurred.
The location of the error handler that has caught the error determines where
execution will resume. If an error is trapped in the same procedure as the error
handler, program execution will resume with the statement that caused the error. If
an error is located in a different procedure from the error handler, program control
reverts to the statement that last called out the procedure containing the error
handler.
Version 6.0
3-271
Example
This example prints an error message if an error occurs during an attempt to open
a file. The Resume statement jumps back into the program code at the done label.
From here, the program exits.
Sub Button_Click
Dim msgtext, userfile
On Error GoTo Debugger
msgtext = "Enter the filename to use:"
userfile = InputBox$(msgtext)
Open userfile For Input As #1
MsgBox "File opened for input."
' ....etc....
Close #1
done:
Exit Sub
Debugger:
msgtext = "Error number " & Err & " occurred at line: " & Erl
MsgBox msgtext
Resume done
End Sub
See Also
3-272
Erl Function on page 3-90, Err Function on page 3-91, Err Statement on page 3-92,
Error Function on page 3-94, Error Statement on page 3-96, On Error Statement on
page 3-235, Appendix B, Trappable Errors
Version 6.0
Right Function
This standard VB function returns a portion of a string beginning at the end of the
string.
Syntax
Right[$](string, length)
Argument
Description
string
length
Returns
Usage
If length is greater than the length of string, Right returns the whole string.
Right accepts any type of string, including numeric values, and will convert the
input value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function will typically return a variant of vartype 8 (string).
If the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
This example checks for the extension .bmp in a filename entered by a user and
activates the Paintbrush application if the file is found. Note that this uses the
Option Compare Text statement to accept either uppercase or lowercase letters for
the filename extension.
Option Compare Text
Sub Button_Click
Dim filename as String
Dim x
filename = InputBox("Enter a .BMP file and path: ")
extension = Right(filename,3)
If extension = "BMP" then
x = Shell("PBRUSH.EXE",1)
Sendkeys "%FO" & filename & "{Enter}", 1
Else
MsgBox "File not found or extension not .BMP."
End If
End Sub
Version 6.0
3-273
See Also
3-274
InStr Function on page 3-163, Left Function on page 3-188, Len Function on
page 3-190, LTrim Function on page 3-205, Mid Function on page 3-207, Mid
Function on page 3-207, RTrim Function on page 3-281, and Trim Function on
page 3-353
Version 6.0
RmDir Statement
RmDir [drive:][\directory\]directory
Argument
Description
drive:
\directory\
directory
Returns
Not applicable
Usage
The directory to be removed must be empty, except for the working ( . ) and parent
( .. ) directories.
The default directory cannot be removed. To remove the default directory, you must
first make another directory current on the drive on which the directory to be
removed resides.
Version 6.0
3-275
Example
This example makes a new temporary directory in C:\ and then deletes it.
Sub Button_Click
Dim path as String
On Error Resume Next
path = CurDir(C)
If path <> "C:\" then
ChDir "C:\"
End If
MkDir "C:\TEMP01"
If Err = 75 then
MsgBox "Directory already exists"
Else
MsgBox "Directory C:\TEMP01 created"
MsgBox "Now removing directory"
RmDir "C:\TEMP01"
End If
End Sub
See Also
3-276
ChDir Statement on page 3-35, ChDrive Statement on page 3-37, CurDir Function
on page 3-56, Dir Function on page 3-79, and MkDir Statement on page 3-213
Version 6.0
Rnd Function
Rnd[(number)]
Argument
Description
number
Returns
Usage
If number is less than zero, the specified number is used as the seed for a pseudorandom number, which is generated every time the Rnd function is executed. If
number is greater than zero, or is omitted, Rnd generates a sequence of pseudorandom numbers, in which each execution of the Rnd function uses the next
number in the sequence. If number is equal to zero, Rnd will use the number most
recently generated.
The same sequence of random numbers is generated whenever Rnd is run, unless
the random number generator is re-initialized by the Randomize statement.
Version 6.0
3-277
Example
This example generates a random string of characters within a range. The Rnd
function is used to set the range between lowercase a and z. The second For...Next
loop is to slow down processing in the first For...Next loop so that Randomize can
be seeded with a new value each time from the Timer function.
Sub Button_Click
Dim x as Integer
Dim y
Dim str1 as String
Dim str2 as String
Dim letter as String
Dim randomvalue
Dim upper, lower
Dim msgtext
upper = Asc("z")
lower = Asc("a")
newline = Chr(10)
For x = 1 to 26
Randomize
randomvalue = Int(((upper - (lower + 1)) * Rnd)
letter = Chr(randomvalue)
str1 = str1 & letter
For y = 1 to 1500
Next y
Next x
msgtext = str1
MsgBox msgtext
End Sub
See Also
3-278
+ lower)
Exp Function on page 3-99, Fix Function on page 3-109, Int Function on page 3-166,
Log Function on page 3-201, Randomize Statement on page 3-260, Sgn Function on
page 3-301, and Sqr Function on page 3-327
Version 6.0
Rset Statement
Description
string
string-expression
Returns
Not applicable
Usage
Version 6.0
3-279
Example
This example uses Rset to right-align an amount entered by the user in a field that
is 15 characters long. It then pads the extra spaces with asterisks (*) and adds a
dollar sign ($) and decimal places (if necessary).
Sub Button_Click
Dim
Dim
Dim
Dim
Dim
amount as String * 15
x as Integer
msgtext as String
replacement as String
position as Integer
replacement = "*"
amount = InputBox("Enter an amount:")
position = InStr(amount,".")
If position = 0 then
amount = Rtrim(amount) & ".00"
End If
Rset amount = "$" & Rtrim(amount)
length = 15-Len(Ltrim(amount))
For x = 1 to length
Mid(amount,x) = replacement
Next x
Msgbox "Formatted amount: " & amount
End Sub
See Also
3-280
Version 6.0
RTrim Function
This standard VB statement copies a string and removes any trailing spaces.
Syntax
RTrim[$](string)
Argument
Description
string
Returns
Usage
RTrim accepts any type of string, including numeric values, and converts the input
value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function will typically return a variant of vartype 8 (string).
If the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
See Also
Left Function on page 3-188, Len Function on page 3-190, LTrim Function on
page 3-205, Mid Function on page 3-207, Mid Statement on page 3-209, Right
Function on page 3-273, and Trim Function on page 3-353
Version 6.0
3-281
Second Function
Second(time)
Argument
Description
time
Returns
Usage
Time can be of any type, including strings, and Second will attempt to convert the
input value to a date-time value.
In order for Second to function without an error, the values passed to it must be in
some form that can be interpreted as a time or date-time value. Thus, 13:26:39 or
1:45:12 PM will return valid results, but 1326 will return a 0.
The return value is a variant of vartype 2 (integer). If the value of time is NULL, a
variant of vartype 1 (Null) is returned.
3-282
Version 6.0
Example
This example displays the last saved date and time for a file whose name is entered
by the user.
Sub Button_Click
Dim filename as String
Dim ftime
Dim hr, min
Dim sec
Dim msgtext as String
i: msgtext = "Enter a filename:"
filename = InputBox(msgtext)
If filename = "" then
Exit Sub
End If
On Error Resume Next
ftime = FileDateTime(filename)
If Err <> 0 then
MsgBox "Error in file name. Try again."
Goto i:
End If
hr = Hour(ftime)
min = Minute(ftime)
sec = Second(ftime)
Msgbox "The file's time is: " & hr &":" &min &":" &sec
End Sub
See Also
Version 6.0
3-283
Seek Function
This standard VB function returns the current file position for an open file.
Syntax
Seek(filenumber)
Argument
Description
filenumber
Returns
Usage
For files opened in random mode, Seek returns the number of the next record to be
read or written. For all other modes, Seek returns the file offset for the next
operation. The first byte in the file is at offset 1, the second byte is at offset 2, and
so on. The return value is a long.
3-284
Version 6.0
Example
This example reads the contents of a sequential file line by line (to a carriage return)
and displays the results. The second subprogram, CreateFile, creates the file
c:\temp001 used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 10-100 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 10 to 100 step 10
Write #1, x
Next x
Close #1
End Sub
Sub Button_Click
Dim testscore as String
Dim x
Dim y
Dim newline
Call CreateFile
Open "c:\temp001" for Input as #1
x = 1
newline = Chr(10)
msgtext = "The test scores are: " & newline
Do Until x = Lof(1)
Line Input #1, testscore
x = x + 1
y = Seek(1)
If y>Lof(1) then
x = Lof(1)
Else
Seek 1,y
End If
msgtext = msgtext & newline & testscore
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
Version 6.0
Get Statement on page 3-132, Open Statement on page 3-238, Put Statement on
page 3-256, and Seek Statement on page 3-286
3-285
Seek Statement
Seek sets the position within an open file for the next read or write operation.
Syntax
Description
filenumber
position
Returns
Not applicable
Usage
If you write to a file after seeking beyond the end of the file, the files length is
extended. Basic will return an error message if a Seek operation is attempted that
specifies a negative or zero position.
For files opened in Random mode, position is a record number; for all other modes,
position is a byte offset. Position is in the range 1 to 2,147,483,647. The first byte or
record in the file is at position 1, the second is at position 2, and so on.
3-286
Version 6.0
Example
This example reads the contents of a sequential file line by line (to a carriage return)
and displays the results. The second subprogram, CreateFile, creates the file
C:\temp001 used by the main subprogram.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 10-100 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 10 to 100 step 10
Write #1, x
Next x
Close #1
End Sub
Sub Button_Click
Dim testscore as String
Dim x
Dim y
Dim newline
Call CreateFile
Open "c:\temp001" for Input as #1
x = 1
newline = Chr(10)
msgtext = "The test scores are: " & newline
Do Until x = Lof(1)
Line Input #1, testscore
x = x + 1
y = Seek(1)
If y>Lof(1) then
x = Lof(1)
Else
Seek 1,y
End If
msgtext = msgtext & newline & testscore
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
Version 6.0
Get Statement on page 3-132, Open Statement on page 3-238, Put Statement on
page 3-256, and Seek Function on page 3-284
3-287
Description
testexpression
expressionList
statement_block
Returns
Not applicable
3-288
Version 6.0
Usage
Version 6.0
3-289
Example
This example tests the attributes for a file, and if it is hidden, changes it to a nonhidden file. For another example, see the VarType Function on page 3-363.
Sub Button_Click
Dim filename as String
Dim attribs, saveattribs as Integer
Dim answer as Integer
Dim archno as Integer
Dim msgtext as String
archno = 32
On Error Resume Next
msgtext = "Enter name of a file:"
filename = InputBox(msgtext)
attribs = GetAttr(filename)
If Err <> 0 then
MsgBox "Error in filename. Re-run Program."
Exit Sub
End If
saveattribs = attribs
If attribs> = archno then
attribs = attribs-archno
End If
Select Case attribs
Case 2,3,6,7
msgtext = "File: " &filename & " is hidden." & Chr(10)
msgtext = msgtext & Chr(10) & " Change it?"
answer = Msgbox(msgtext,308)
If answer = 6 then
SetAttr filename, saveattribs - 2
Msgbox "File is no longer hidden."
Exit Sub
End If
MsgBox "Hidden file not changed."
Case Else
MsgBox "File was not hidden."
End Select
End Sub
See Also
3-290
Version 6.0
SendKeys Statement
Description
string
wait
An integer expression specifying whether to wait until all keys are processed
before continuing program execution, where:
-1 = wait
0 = dont wait
Returns
Not applicable
Usage
to specify Shift
to specify Alt
to specify Control
Parentheses can be used to specify that the Shift, Alt, or Control key should be
pressed with a group of characters. For example, %(abc)is equivalent to %a%b%c.
Version 6.0
3-291
SHIFT key
ALT key
CTRL key
()
{}
[]
3-292
Key
Keyword
Backspace
Break
{BREAK}
Caps Lock
{CAPSLOCK}
Clear
{CLEAR}
Delete
{DELETE} or {DEL}
Down Arrow
{DOWN}
End
{END}
{ENTER}
Esc
{ESCAPE} or {ESC}
Version 6.0
Key
Keyword
Help
{HELP}
Home
{HOME}
Insert
{INSERT}
Left Arrow
{LEFT}
Num Lock
{NUMLOCK}
Page Down
{PGDN}
Page Up
{PGUP}
Right Arrow
{RIGHT}
Scroll Lock
{SCROLLLOCK}
Tab
{TAB}
Up Arrow
{UP}
To send one of the function keys (F1F15), simply enclose the name of the key
inside braces. For example, to send F5 use {F5}.
Note that special keywords can be used in combination with +, %, and ^. For
example: %{TAB} means ALT+Tab. Also, you can send several special keys in the
same way as you would send several normal keys: {UP 25} sends 25 up arrows.
SendKeys can send keystrokes only to the currently active application. Therefore,
you have to use the AppActivate statement to activate an application before sending
keys (unless it is already active).
SendKeys cannot be used to send keys to an application that was not designed to
run under Windows.
Version 6.0
3-293
Example
This example starts the Windows Phone Dialer application and dials a phone
number entered by the user.
Sub Button_Click
Dim phonenumber, msgtext
Dim x
phonenumber = InputBox("Type telephone number to call:")
x = Shell("Terminal.exe", -1)
SendKeys "%N" & phonenumber & "{Enter}", -1
msgtext = "Dialing..."
MsgBox msgtext
End Sub
See Also
AppActivate Statement on page 3-19, DoEvents Statement on page 3-82, and Shell
Function on page 3-302
Service_InvokeMethod Event
Service_PreInvokeMethod Event
3-294
Version 6.0
Set Statement
Description
variableName
objectExpression
Returns
Not applicable
Usage
Set differs from Let in that Let assigns an expression to a Siebel VB variable. For
example,
Version 6.0
Set o1 = o2
Let o1 = o2
3-295
Example
See Also
3-296
Version 6.0
SetAttr Statement
This standard VB statement sets the file attributes for a specified file.
Syntax
Description
pathname
attributes
Returns
Not applicable
Usage
Wildcards are not allowed in pathname. If the file is open, you can modify its
attributes, but only if it is opened for Read access. Here is a description of attributes
that can be modified:
Value
Meaning
Normal file
Read-only file
Hidden file
System file
32
Example
See Also
Version 6.0
3-297
SetFieldValue Method
SetFieldValue assigns the new value to the named field for the current row of a
Siebel business component. This method is used with business component objects.
For details, see the Siebel Object Interfaces Reference.
SetFormattedFieldValue Method
SetFormattedFieldValue assigns the new value to the named field for the current
row of a Siebel business component. SetFormattedFieldValue accepts the field value
in the current local format. This method is used with business component objects.
For details, see the Siebel Object Interfaces Reference.
SetNamedSearch Method
SetProfileAttr Method
SetProperty Method
3-298
Version 6.0
SetSearchExpr Method
SetSearchSpec Method
SetSearchSpec sets the search specification for a particular field in a Siebel business
component. This method must be called before ExecuteQuery. It is used with
business component objects. For details, see the Siebel Object Interfaces Reference.
SetSharedGlobal Method
SetSortSpec Method
SetType Method
SetType assigns a data value to a type member of a property set. For details, see the
Siebel Object Interfaces Reference.
Version 6.0
3-299
SetUserProperty Method
Sets the value of a named Siebel business component user property. The user
properties are similar to instance variables of a business component. This method
is used with business component objects. For details, see the Siebel Object Interfaces
Reference.
SetValue Method
The SetValue method sets the contents of a specified control on a Siebel applet to
the value indicated. It is also used to assign a data value to a value member of a
property set. This method is used with control objects and property sets. For details,
see the Siebel Object Interfaces Reference.
SetViewMode Method
SetViewMode sets the visibility type for a Siebel business component. This method
is used with business component objects. For details, see the Siebel Object Interfaces
Reference.
3-300
Version 6.0
Sgn Function
Returns
Sgn(number)
Argument
Description
number
Example
This example tests the value of the variable profit and displays 0 for profit if it is a
negative number. The subroutine uses Sgn to determine whether profit is positive,
negative, or zero.
Sub Button_Click
Dim profit as Single
Dim expenses
Dim sales
expenses = InputBox("Enter total expenses: ")
sales = InputBox("Enter total sales: ")
profit = Val(sales)-Val(expenses)
If Sgn(profit) = 1 then
MsgBox "Yeah! We turned a profit!"
ElseIf Sgn(profit) = 0 then
MsgBox "Okay. We broke even."
Else
MsgBox "Uh, oh. We lost money."
End If
End Sub
See Also
Version 6.0
Exp Function on page 3-99, Fix Function on page 3-109, Int Function on page 3-166,
Log Function on page 3-201, Rnd Function on page 3-277, and Sqr Function on
page 3-327
3-301
Shell Function
This standard VB function starts a Windows application and returns its task ID.
Syntax
Shell(pathname, [windowStyle])
Argument
Description
pathname
windowStyle
Returns
The task ID for the program, a unique number that identifies the running program.
Usage
Shell runs an executable program. Pathname can be the name of any valid .COM,
.EXE, .BAT, or .PIF file. Arguments and command line switches can be included. If
pathname is not a valid executable file name, or if Shell cannot start the program,
an error message occurs.
If windowStyle is not specified, the default of windowStyle is 1 (normal window
with focus).
Example
This example opens Microsoft Excel upon the click of a button. For other examples,
see the DoEvents Statement on page 3-82, the Right Function on page 3-273, and
the SendKeys Statement on page 3-291.
Sub Button1_Click
Dim i as long
i = Shell("C:\Program Files\Microsoft Office\Office\EXCEL.EXE",1)
End Sub
See Also
3-302
Version 6.0
ShowStatus Method
ShowStatus displays a message string in the status bar at the bottom of the Siebel
Applications window. This method is used with the application object. For details,
see the Siebel Object Interfaces Reference.
Version 6.0
3-303
Sin Function
Sin(number)
Argument
Description
number
Returns
Usage
The return value will be between -1 and 1. The return value is single precision if the
angle is an integer, currency, or single precision value; double precision for a long,
variant, or double-precision value. The angle is specified in radians and can be
either positive or negative.
To convert degrees to radians, multiply by (PI/180). The value of PI is 3.14159.
Example
This example finds the height of a building, given the length of the roof and the roof
pitch.
Sub Button_Click
Dim height, rooflength, pitch, msgtext As String
Const PI = 3.14159
Const conversion = PI/180
pitch = InputBox("Enter the roof pitch in degrees:")
pitch = pitch * conversion
rooflength = InputBox("Enter the length of the roof in feet:")
height = Sin(pitch) * rooflength
msgtext = "The height of the building is "
msgtext = msgtext & Format(height, "##.##") & " feet."
MsgBox msgtext
End Sub
See Also
3-304
Atn Function on page 3-23, Cos Function on page 3-49, Tan Function on page 3-341,
and Appendix C, Derived Trigonometric Functions
Version 6.0
Space Function
Space[$](number)
Argument
Description
number
Returns
Usage
Number can be any numeric data type, but will be rounded to an integer. Number
must be between 0 and 32,767.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
Example
See Also
Version 6.0
3-305
Spc Function
Spc(number)
Argument
Description
number
Returns
Usage
If number is less than the total line width, Spc outputs number spaces.
If number is greater than the total line width, Spc outputs number Mod width
spaces.
If the difference between the current print position and the output line width
(call this difference x) is less than number or number Mod width, then Spc skips
to the next line and outputs number - x spaces.
To set the width of a print line, use the Width statement.
3-306
Version 6.0
Example
This example outputs five spaces and the string ABCD to a file. The five spaces are
derived by taking 15 Mod 10, or the remainder of dividing 15 by 10.
Sub Button_Click
Dim str1 as String
Dim x as String * 10
str1 = "ABCD"
Open "C:\temp001" For Output As #1
Width #1, 10
Print #1, Spc(15); str1
Close #1
Open "C:\TEMP001" as #1 Len = 12
Get #1, 1,x
Msgbox "The contents of the file is: " & x
Close #1
Kill "C:\temp001"
End Sub
See Also
Version 6.0
Print Statement on page 3-254, Space Function on page 3-305, Tab Function on
page 3-339, and Width Statement on page 3-371
3-307
SQLClose Function
This custom VB function disconnects from an ODBC data source connection that
was established by SQLOpen.
Syntax
Returns
Usage
SQLClose(connection)
Argument
Description
connection
Meaning
Successful disconnection
-1
For information about named arguments, see Named Arguments on page 2-9 and
the Call Statement on page 3-29.
Caution: This function, as well as the other SQL functions available
in Siebel VB, should not be used to query the underlying database.
Use the Siebel Object Interfaces to query Siebel data. Use the SQL
functions only to query non-Siebel data.
3-308
Version 6.0
Example
This example opens the data source named SblTest, gets the names in the ODBC
data sources, and closes the connection.
Sub Button_Click
' Declarations
Dim
Dim
Dim
Dim
Dim
'
outputStr As String
connection As Long
prompt As Integer
datasources(1 To 50) As Variant
retcode As Variant
prompt = 5
Open the data source "SblTest"
connection = SQLOpen("DSN = SblTest", outputStr, prompt: = 5)
action1 = 1 ' Get the names of the ODBC data sources
retcode = SQLGetSchema(connection: = connection,action: _
= 1,qualifier: = qualifier, ref: = datasources())
'
End Sub
See Also
Version 6.0
3-309
SQLError Function
This custom VB function can be used to retrieve detailed information about errors
that might have occurred when making an ODBC function call. It returns errors for
the last ODBC function and the last connection.
Syntax
SQLError(destination())
Argument
Description
destination
Returns
Not applicable
Usage
Detailed information for each detected error is returned to the caller in the
destination array. Each row of the destination array will be filled with information
for one error. The elements of each row will be filled with the following data:
Element 1:
Element 2:
Element 3:
Note that information for more than one error may be returned in the destination
array. A 0 in the first element of a row indicates the end of error information in the
destination array.
If there are no errors from a previous ODBC function call, then a 0 is returned in the
callers array at (1,1). If the array is not two dimensional or does not provide for the
return of the three elements above, then an error message is returned in the callers
array at (1,1).
Caution: This function, as well as the other SQL functions available
in Siebel VB, should not be used to query the underlying database.
Use the Siebel Object Interfaces to query Siebel data. Use the SQL
functions only to query non-Siebel data.
3-310
Version 6.0
Example
See Also
Version 6.0
3-311
SQLExecQuery Function
Returns
Usage
SQLExecQuery(connection, query)
Argument
Description
connection
query
The number of columns in the result set for SQL SELECT statements as a variant.
Select Statement
Return Value
UPDATE
INSERT
DELETE
If the function is unable to execute the query on the specified data source, or if the
connection is invalid, a negative error code is returned.
If SQLExecQuery is called and there are any pending results on that connection, the
pending results are replaced by the new results.
Caution: This function, as well as the other SQL functions available
in Siebel VB, should not be used to query the underlying database.
Use the Siebel Object Interfaces to query Siebel data. Use the SQL
functions only to query non-Siebel data.
3-312
Version 6.0
Example
As Variant
See Also
Version 6.0
3-313
SQLGetSchema Function
Returns
Description
connection
action
qualifier
A string
ref()
An array of type variant for the results appropriate to the action requested;
it must be an array even if only one dimension with one element
3-314
(Sheet 1 of 2)
Action
Value
Returns
Version 6.0
Table 3-1.
Usage
(Sheet 2 of 2)
Action
Value
Returns
The name of the DBMS the data source uses (for example, DB2)
10
11
12
13
14
Version 6.0
3-315
Example
This example opens the data source named SblTest, gets the names in the ODBC
data sources, and closes the connection.
Sub Button_Click
' Declarations
Dim
Dim
Dim
Dim
Dim
outputStr As String
connection As Long
prompt As Integer
datasources(1 To 50) As Variant
retcode As Variant
prompt = 5
' Open the data source "SblTest"
connection = SQLOpen("DSN = SblTest", outputStr, prompt: = 5)
action1 = 1 ' Get the names of the ODBC data sources
retcode = SQLGetSchema(connection: = connection, action: = 1, _
qualifier: = qualifier, ref: = datasources())
' Close the data source connection
retcode = SQLClose(connection)
End Sub
See Also
3-316
Version 6.0
SQLOpen Function
Description
connectString
outputString
prompt
The following table lists the values for prompt. When prompt is omitted, 2 is
assumed.
Returns
Version 6.0
Prompt
Value
Meaning
Driver dialog box is displayed only when the specification is not sufficient to
make the connection
The same as 2, except that dialog boxes that are not required are unavailable
and cannot be modified
Driver dialog box is not displayed; if the connection is not successful, an error
is returned
A long integer representing a unique connection ID, which can be used with other
ODBC functions. The completed connection string is returned in outputString if this
argument is used. If the connection cannot be established, then an ODBC error with
a negative numeric value is returned. Test this value with the SQLError Function on
page 3-310.
3-317
Usage
The connectString variable generally takes the following form; however, it must
follow the format dictated by the ODBC driver you are using.
DSN = dataSourceName; UID = loginID; PWD = password
As the example below shows, all of the parts of this string may not be required; you
must supply whatever information is required by the ODBC driver in order to make
the connection. For details on the connect string used to access a Siebel application,
see Siebel Tech Note #206.
Caution: This function, as well as the other SQL functions available
in Siebel VB, should not be used to query the underlying database.
Use the Siebel Object Interfaces to query Siebel data. Use the SQL
functions only to query non-Siebel data.
Example
This example opens the data source named SblTest, gets the names in the ODBC
data sources, and closes the connection.
Sub Button_Click
' Declarations
Dim
Dim
Dim
Dim
Dim
outputStr As String
connection As Long
prompt As Integer
datasources(1 To 50) As Variant
retcode As Variant
prompt = 5
' Open the datasource "SblTest"
connection = SQLOpen("DSN = SblTest", outputStr, prompt: = 5)
action1 = 1 ' Get the names of the ODBC data sources _
retcode = SQLGetSchema(connection: = connection, _
action: = 1, qualifier: = qualifier, ref: = datasources())
' Close the data source connection
retcode = SQLClose(connection)
End Sub
3-318
Version 6.0
See Also
Version 6.0
3-319
SQLRequest Function
Description
connectString
query
An SQL query
outputString
prompt
columnNames
ref()
1. See the SQLOpen Function on page 3-317 for details on the connect string.
2. See the SQLOpen Function on page 3-317 for a table of values for prompt.
Returns
3-320
Version 6.0
Usage
Example
This example opens the data source SVBTESTW, executes the query specified in
query, and returns the results in destination().
Sub Button_Click
' Declarations
Dim destination(1 To 50, 1 To 125)
Dim prompt As integer
As Variant
See Also
Version 6.0
3-321
SQLRetrieve Function
This custom VB function fetches the results of a pending query on the connection
specified by connection and returns the results in the destination() array.
Syntax
Returns
3-322
Description
connection
destination()
maxColumns
maxRows
columnNames
rowNumbers
fetchFirst
Returns
Success
-1
Version 6.0
Usage
Version 6.0
3-323
Example
As Variant
See Also
3-324
Version 6.0
SQLRetrieveToFile Function
This custom VB function fetches the results of a pending query on the connection
specified by connection& and stores them in the file specified by destination.
Syntax
Description
connection
destination
columnNames
Returns
Usage
Version 6.0
3-325
Example
This example opens a connection to a data source and retrieves information to a file.
Sub Button_Click
'Declarations
Dim connection As Long
Dim destination(1 To 50, 1 To 125)
Dim retcode As long
As Variant
See Also
3-326
Version 6.0
Sqr Function
Sqr(number)
Argument
Description
number
Returns
Usage
The return value is single precision for an integer, currency, or single precision
numeric expression; double precision for a long, variant, or double-precision
numeric expression.
Example
See Also
Exp Function on page 3-99, Fix Function on page 3-109, Int Function on page 3-166,
Log Function on page 3-201, Rnd Function on page 3-277, and Sgn Function on
page 3-301
Version 6.0
3-327
Static Statement
Description
variableName
type
The data type of the variable; if not specified, the type is variant
Returns
Not applicable
Usage
Variables declared with the Static statement retain their value as long as the
program is running. The syntax of Static is exactly the same as the syntax of the
Dim statement.
All variables of a procedure can be made static by using the Static keyword in a
definition of that procedure. See the Function...End Function Statement on
page 3-127 or the Sub...End Sub Statement on page 3-336 for more information.
Example
This example puts account numbers to a file using the record variable grecord and
then prints them again.
Type acctrecord
acctno as Integer
End Type
Sub Button_Click
Static grecord as acctrecord
Dim x
Dim total
x = 1
grecord.acctno = 1
On Error Resume Next
Open "c:\temp001" For Output as #1
Do While grecord.acctno <> 0
i: grecord.acctno = InputBox("Enter 0 or new account #" _
& x & ":")
3-328
Version 6.0
See Also
Version 6.0
3-329
Stop Statement
Stop
Argument
Description
Not applicable
Returns
Not applicable
Usage
Example
3-330
Version 6.0
Str Function
Str[$](number)
Argument
Description
number
Returns
Usage
The precision in the returned string is single precision for an integer or singleprecision numeric expression; double precision for a long or double-precision
numeric expression, and currency precision for currency. Variants return the
precision of their underlying vartype.
The dollar sign ($) in the function name is optional. If it is specified, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
Example
This example prompts for two numbers, adds them, then shows them as a
concatenated string.
Sub Button_Click
Dim x as Integer
Dim y as Integer
Dim str1 as String
Dim value1 as Integer
x = InputBox("Enter a value for x: ")
y = InputBox("Enter a value for y: ")
MsgBox "The sum of these numbers is: " & x + y
str1 = Str(x) & Str(y)
MsgBox "The concatenated string for these numbers is: _
" & str1
End Sub
See Also
Version 6.0
3-331
StrComp Function
This standard VB function compares two strings and returns an integer specifying
the result of the comparison.
Syntax
Description
string1
string2
compare
Returns
Usage
Meaning
-1
string1 = string2
>1
Null
3-332
Version 6.0
Example
See Also
Version 6.0
InStr Function on page 3-163 and Option Compare Statement on page 3-244
3-333
String Function
String[$](number, character)
Syntax B
Description
number
character
stringExpression
Returns
Usage
3-334
Version 6.0
Example
This example places asterisks (*) in front of a string that is printed as a payment
amount.
Sub Button_Click
Dim str1 as String
Dim size as Integer
i: str1 = InputBox("Enter an amount up to 999,999.99: ")
If Instr(str1,".") = 0 then
str1 = str1 + ".00"
End If
If Len(str1)>10 then
MsgBox "Amount too large. Try again."
Goto i
End If
size = 10-Len(str1)
'Print amount in a space on a check allotted for 10 characters
str1 = String(size,Asc("*")) & str1
Msgbox "The amount is: $" & str1
End Sub
See Also
Version 6.0
3-335
Description
name
parameter
type
Returns
Not applicable
Usage
A call to a subprogram stands alone as a separate statement. (See the Call Statement
on page 3-29.) Recursion is supported.
The data type of a parameter can be specified by using a type character or by using
the As clause. Record parameters are declared by using an As clause and a type that
has previously been defined using the Type statement. Array parameters are
indicated by using empty parentheses after the parameter. The array dimensions are
not specified in the Sub statement. All references to an array within the body of the
subprogram must have a consistent number of dimensions.
If a parameter is declared as Optional, its value can be omitted when the function
is called. Only variant parameters can be declared as optional, and all optional
parameters must appear after all required parameters in the Sub statement. The
function IsMissing (see page 3-177) must be used to check whether an optional
parameter was omitted by the user. See Named Arguments on page 2-9 and the
Call Statement on page 3-29 for more information on using named parameters.
The procedure returns to the caller when the End Sub statement is reached or when
an Exit Sub statement is executed.
The Static keyword specifies that all the variables declared within the subprogram
will retain their values as long as the program is running, regardless of the way the
variables are declared.
3-336
Version 6.0
The Private keyword specifies that the procedures will not be accessible to functions
and subprograms from other modules. Only procedures defined in the same module
will have access to a Private subprogram.
Basic procedures use the call by reference convention. This means that if a
procedure assigns a value to a parameter, it will modify the variable passed by the
caller.
Use Function rather than Sub (see page 3-127) to define a procedure that has a
return value.
Caution: You cannot write your own functions or subprograms
directly in the methods and events exposed in Siebel Tools. You can
write functions and subprograms in the (general) (declarations)
section of a given method script. However, if you want your routines
to be available throughout the program, you can use the
Application_PreInvokeMethod or an external .DLL file as a central
place to write them. See Siebel Tech Notes #207 and #217 for details.
NOTE: If you create more than one function or subprogram in the (general)
(declarations) section, be sure that any function or subprogram that may be called
by other user-defined functions and subprograms appears before the procedure that
calls it. Otherwise, you will not be able to compile your procedures.
Example
See Also
Version 6.0
3-337
SuppressNotification Method
SuppressNotification disables the updates to the user interface that result from
changes to a Siebel business component. This method is used with business
component objects. For details, see the Siebel Object Interfaces Reference.
3-338
Version 6.0
Tab Function
This standard VB function moves the current print position to the column specified.
Syntax
Tab(position)
Argument
Description
position
Returns
Not applicable
Usage
The Tab function can be used only inside a Print statement. The leftmost print
position is position number 1.
When the Print statement is used, the Tab function will use the following rules for
determining the next print position:
If position is less than the total line width, the new print position is position.
If position is greater than the total line width, the new print position is n Mod
width.
If the current print position is greater than position or position Mod width, Tab
skips to the next line and sets the print position to position or position Mod
width.
To set the width of a print line, use the Width statement.
Version 6.0
3-339
Example
This example prints the octal values for the numbers from 1 to 25. It uses Tab to put
five character spaces between the values.
Sub Button_Click
Dim x As Integer
Dim y As String
For x = 1 to 25
y = Oct$(x)
Print x Tab(10) y
Next x
End Sub
See Also
3-340
Print Statement on page 3-254, Space Function on page 3-305, Spc Function on
page 3-306, Width Statement on page 3-371
Version 6.0
Tan Function
Tan(number
Argument
Description
number
Returns
Usage
Example
This example finds the height of the exterior wall of a building, given its roof pitch
and the length of the building.
Sub Button_Click
Dim bldglen, wallht
Dim pitch
Dim msgtext
Const PI = 3.14159
Const conversion = PI/180
On Error Resume Next
pitch = InputBox("Enter the roof pitch in degrees:")
pitch = pitch * conversion
bldglen = InputBox("Enter the length of the building in _
feet:")
wallht = Tan(pitch) * (bldglen/2)
msgtext = "The height of the building is: " & Format _
(wallht, "##.00")
MsgBox msgtext
End Sub
See Also
Version 6.0
Atn Function on page 3-23, Cos Function on page 3-49, Sin Function on page 3-304,
and Appendix C, Derived Trigonometric Functions
3-341
theApplication Method
The method theApplication is a global Siebel method that returns the unique object
of type Application. This is the root of all objects within the Siebel Applications
object hierarchy. Use this method to determine the object reference of the
application, which is later used to find other objects, or to invoke methods on the
application object. For details, see the Siebel Object Interfaces Reference.
3-342
Version 6.0
Time Function
Time[$]
Argument
Description
Not applicable
Returns
Usage
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function returns a variant of vartype 8 (string).
Version 6.0
3-343
Example
This example writes data to a file if it hasnt been saved within the last 2 minutes.
Sub Button_Click
Dim tempfile
Dim filetime, curtime
Dim msgtext
Dim acctno(100) as Single
Dim x, I
tempfile = "c:\temp001"
Open tempfile For Output As #1
filetime = FileDateTime(tempfile)
x = 1
I = 1
acctno(x) = 0
Do
curtime = Time
acctno(x) = InputBox("Enter an account number (99 to end):")
If acctno(x) = 99 then
For I = 1 to x -1
Write #1, acctno(I)
Next I
Exit Do
ElseIf (Minute(filetime) + 2)< = Minute(curtime) then
For I = I to x
Write #1, acctno(I)
Next I
End If
x = x + 1
Loop
Close #1
x = 1
msgtext = "Contents of c:\temp001 is:" & Chr(10)
Open tempfile for Input as #1
Do While Eof(1) <> -1
Input #1, acctno(x)
msgtext = msgtext & Chr(10) & acctno(x)
x = x + 1
Loop
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub
See Also
3-344
Date Function on page 3-61, Date Statement on page 3-62, Time Statement on
page 3-345, Timer Function on page 3-347, TimeSerial Function on page 3-349, and
TimeValue Function on page 3-350
Version 6.0
Time Statement
Time[$] = expression
Placeholder
Meaning
expression
Returns
Not applicable
Usage
When Time (with the dollar sign, $) is used, the expression must evaluate to a string
of one of the following forms:
hh
hh:mm
Version 6.0
3-345
Example
See Also
3-346
Date Function on page 3-61, Date Statement on page 3-62, Time Function on
page 3-343, TimeSerial Function on page 3-349, and TimeValue Function on
page 3-350
Version 6.0
Timer Function
This standard VB function returns the number of seconds that have elapsed since
midnight.
Syntax
Timer
Argument
Description
Not applicable
Returns
Usage
The Timer function can be used in conjunction with the Randomize statement to
seed the random number generator.
Example
Version 6.0
3-347
For y = 1 to 8
For x = 1 to 8
If y <> x then
If value(y) = value(x) then
value(x) = value(x) + 1
End If
End If
Next x
Next y
For x = 1 to 8
msgtext = msgtext & value(x) & " "
Next x
MsgBox msgtext
End Sub
See Also
3-348
Version 6.0
TimeSerial Function
Description
hour
minute
second
Returns
Usage
You also can specify relative times for each argument by using a numeric expression
representing the number of hours, minutes, or seconds before or after a certain
time.
Example
See Also
Version 6.0
DateSerial Function on page 3-64, DateValue Function on page 3-65, Hour Function
on page 3-152, Minute Function on page 3-211, Now Function on page 3-226,
Second Function on page 3-282, and TimeValue Function on page 3-350
3-349
TimeValue Function
TimeValue(time)
Argument
Description
time
Returns
Usage
Example
This example writes a variable to a disk file based on a comparison of its last saved
time and the current time. Note that all the variables used for the TimeValue
function are dimensioned as double, so that calculations based on their values will
work properly.
Sub Button_Click
Dim tempfile As String
Dim ftime As Variant
Dim filetime as Double
Dim curtime as Double
Dim minutes as Double
Dim acctno(100) as Integer
Dim x, I
tempfile = "C:\TEMP001"
Open tempfile For Output As 1
ftime = FileDateTime(tempfile)
filetime = TimeValue(ftime)
minutes = TimeValue("00:02:00")
x = 1
I = 1
acctno(x) = 0
Do
curtime = TimeValue(Time)
acctno(x) = InputBox("Enter an account number (99 to _
end):")
If acctno(x) = 99 then
3-350
Version 6.0
For I = I to x-1
Write #1, acctno(I)
Next I
Exit Do
ElseIf filetime + minutes< = curtime then
For I = I to x
Write #1, acctno(I)
Next I
End If
x = x + 1
Loop
Close #1
x = 1
msgtext = "You entered:" & Chr(10)
Open tempfile for Input as #1
Do While Eof(1) <> -1
Input #1, acctno(x)
msgtext = msgtext & Chr(10) & acctno(x)
x = x + 1
Loop
MsgBox msgtext
Close #1
Kill "C:\TEMP001"
End Sub
See Also
Version 6.0
DateSerial Function on page 3-64, DateValue Function on page 3-65, Hour Function
on page 3-152, Minute Function on page 3-211, Now Function on page 3-226,
Second Function on page 3-282, and TimeSerial Function on page 3-349
3-351
Trace Method
The Trace method appends a message to the trace file. Trace is useful for debugging
SQL query execution. It is used with the application object. For details, see the
Siebel Object Interfaces Reference.
TraceOff Method
TraceOff turns off the tracing started by the TraceOn method. It is used with the
application object. For details, see the Siebel Object Interfaces Reference.
TraceOn Method
TraceOn turns on the tracking of allocations and de-allocations of Siebel objects and
SQL statements generated by the Siebel application. It is used with the application
object. For details, see the Siebel Object Interfaces Reference.
3-352
Version 6.0
Trim Function
This standard VB function returns a copy of a string after removing all leading and
trailing spaces.
Syntax
Trim[$](string)
Argument
Description
string
Returns
Usage
Trim accepts expressions of type string. Trim accepts any type of string, including
numeric values, and converts the input value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function typically returns a variant of vartype 8 (string). If
the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
This example removes leading and trailing spaces from a string entered by the user.
Sub Button_Click
Dim userstr as String
userstr = InputBox("Enter a string with leading/trailing _
spaces")
MsgBox "The string is: " & Trim(userstr) & " with _
nothing after it."
End Sub
See Also
Version 6.0
Left Function on page 3-188, Len Function on page 3-190, LTrim Function on
page 3-205, Mid Function on page 3-207, Mid Statement on page 3-209, Right
Function on page 3-273, and RTrim Function on page 3-281
3-353
Type Statement
Type userType
field1 As type1
field2 As type2
...
End Type
Argument
Description
userType
field1, field2
type1, type2
Returns
Not applicable
Usage
The user-defined type declared by Type can be used in a Dim statement to declare
a record variable. A user-defined type is sometimes referred to as a record type or a
structure type.
Field cannot be an array. However, arrays of records are allowed.
The Type statement is not valid inside a procedure definition. It must be placed in
the (general) (declarations) section, shown in Figure 3-4 on page 3-242.
To access the fields of a record, use syntax of the form:
recordName.fieldName
To access the fields of an array of records, use syntax of the form:
arrayName(index).fieldName
3-354
Version 6.0
This example shows a Type and Dim statement for a record. You must define a
record type before you can declare a record variable. The subroutine then references
a field within the record.
Type Testrecord
Custno As Integer
Custname As String
End Type
Sub Button_Click
Dim myrecord As Testrecord
Dim msgText As String
i:
myrecord.custname = InputBox("Enter a customer name:")
If myrecord.custname = "" then
Exit Sub
End If
msgText = "Is the name " & myrecord.custname &" correct? (Y/N)"
answer = InputBox(msgText)
If answer = "Y" or answer = "y" then
MsgBox "Thank you."
Else
MsgBox "Try again."
Goto i
End If
End Sub
See Also
Version 6.0
3-355
Typeof Function
Meaning
objectVariable
className
Returns
Usage
Typeof can only be used in an If statement and cannot be combined with other
Boolean operators. That is, Typeof can only be used exactly as shown in the syntax
above.
To test if an object does not belong to a class, use the following code structure:
If Typeof objectVariable Is className Then
[Perform some action.]
Else
[Perform some action.]
End If
See Also
3-356
Version 6.0
UBound Function
This standard VB function returns the upper bound of the subscript range for the
specified array.
Syntax
UBound(arrayName[, dimension ])
Argument
Description
arrayName
dimension
Returns
The upper bound of the subscript range for the specified dimension of the specified
array.
Usage
The dimensions of an array are numbered starting with 1. If the dimension is not
specified, 1 is used as a default.
LBound can be used with UBound to determine the length of an array.
Version 6.0
3-357
Example
This example resizes an array if the user enters more data than can fit in the array.
It uses LBound and UBound to determine the existing size of the array and ReDim
to resize it. Option Base sets the default lower bound of the array to 1.
Option Base 1
Sub Button_Click
Dim arrayvar() as Integer
Dim count as Integer
Dim answer as String
Dim x, y as Integer
Dim total
total = 0
x = 1
count = InputBox("How many test scores do you have?")
ReDim arrayvar(count)
start:
Do until x = count + 1
arrayvar(x) = InputBox("Enter test score #" &x & ":")
x = x + 1
Loop
answer = InputBox$("Do you have more scores? (Y/N)")
If answer = "Y" or answer = "y" then
count = InputBox("How many more do you have?")
If count <> 0 then
count = count + (x-1)
ReDim Preserve arrayvar(count)
Goto start
End If
End If
x = LBound(arrayvar,1)
count = UBound(arrayvar,1)
For y = x to count
total = total + arrayvar(y)
Next y
MsgBox "The average of the " & count & " scores is: " & _
Int(total/count)
End Sub
See Also
3-358
Dim Statement on page 3-73, Global Statement on page 3-144, LBound Function on
page 3-185, Option Base Statement on page 3-241, ReDim Statement on page 3-263,
and Static Statement on page 3-328
Version 6.0
UCase Function
This standard VB function returns a copy of a string after converting all lowercase
letters to uppercase.
Syntax
UCase[$](string)
Argument
Description
string
Returns
Usage
The translation is based on the country specified in the Windows Control Panel.
UCase accepts any type of argument and will convert the input value to a string.
The dollar sign ($) in the function name is optional. If it is included, the return type
is string. Otherwise the function typically returns a variant of vartype 8 (string). If
the value of string is NULL, a variant of vartype 1 (Null) is returned.
Example
See Also
Version 6.0
3-359
UndoRecord Method
3-360
Version 6.0
Unlock Statement
Description
filenumber
The file number used in the Open statement to open the file
record
start
end
Returns
Not applicable
Usage
For Binary mode, start and end are byte offsets. For random mode, start and end are
record numbers. If start is specified without end, then only the record or byte at start
is locked. If To end is specified without start, then all records or bytes from record
number or offset 1 to end are locked.
For input, output, and append modes, start and end are ignored and the whole file
is locked.
Lock and Unlock always occur in pairs with identical parameters. All locks on open
files must be removed before closing the file, or unpredictable results will occur.
Example
For an example of the Unlock statement, see the Lock Statement on page 3-198.
See Also
Version 6.0
3-361
Val Function
This standard VB function returns the numeric value of the first number found in a
string.
Syntax
Val(string)
Argument
Description
string
Returns
The value of the first number in string. If no number is found, Val returns 0.
Usage
Example
This example tests the value of the variable profit and displays 0 for profit if it is a
negative number. The subroutine uses Sgn to determine whether profit is positive,
negative, or zero.
Sub Button_Click
Dim profit as Single
Dim expenses
Dim sales
expenses = InputBox("Enter total expenses: ")
sales = InputBox("Enter total sales: ")
profit = Val(sales)-Val(expenses)
If Sgn(profit) = 1 then
MsgBox "Yeah! We turned a profit!"
ElseIf Sgn(profit) = 0 then
MsgBox "Okay. We broke even."
Else
MsgBox "Uh, oh. We lost money."
End If
End Sub
See Also
3-362
CCur Function on page 3-32, CDbl Function on page 3-34, CInt Function on
page 3-40, CLng Function on page 3-44, CSng Function on page 3-52, CStr Function
on page 3-54, CVar Function on page 3-58, CVDate Function on page 3-59, Format
Function on page 3-114, and Str Function on page 3-331
Version 6.0
VarType Function
This standard VB function returns the variant type of the specified variant variable.
Syntax
Returns
Version 6.0
VarType(varName)
Argument
Description
varName
Representation
(Empty)
Null
Integer
Long
Single
Double
Currency
Date
String
Object
3-363
Example
3-364
Version 6.0
See Also
Version 6.0
IsDate Function on page 3-174, IsEmpty Function on page 3-175, IsNull Function on
page 3-179, and IsNumeric Function on page 3-181
3-365
WebApplet_InvokeMethod Event
WebApplet_PreInvokeMethod Event
WebApplet_ShowControl Event
This event allows scripts to modify the HTML generated by the Siebel Web Engine
to render a control on a web page in a .COM application. For details, see the Siebel
Object Interfaces Reference.
WebApplet_ShowListColumn Event
This event allows scripts to modify the HTML generated by the Siebel Web Engine
to render a list column on a web page. For details, see the Siebel Object Interfaces
Reference.
3-366
Version 6.0
Weekday Function
This standard VB function returns the day of the week for a specified date-time
value.
Syntax
Weekday(date)
Argument
Description
date
Returns
Usage
Weekday accepts any expression, including strings, and attempts to convert the
input value to a date value.
The return value is a variant of vartype 2 (integer). If the value of date is NULL, a
variant of vartype 1 (Null) is returned.
Example
This example finds the day of the week on which New Years Day will fall in the
year 2002.
Sub Button_Click
Dim newyearsday
Dim daynumber
Dim msgtext
Dim newday as Variant
Const newyear = 2002
Const newmonth = 1
Let newday = 1
newyearsday = DateSerial(newyear,newmonth,newday)
daynumber = Weekday(newyearsday)
msgtext = "New Year's day 2002 falls on a " & _
Format(daynumber, "dddd")
MsgBox msgtext
End Sub
Version 6.0
3-367
See Also
3-368
Date Function on page 3-61, Date Statement on page 3-62, Day Function on
page 3-67, Hour Function on page 3-152, Minute Function on page 3-211, Month
Function on page 3-214, Now Function on page 3-226, Second Function on
page 3-282, and Year Function on page 3-376
Version 6.0
While...Wend Statement
While condition
statement_block
Wend
Placeholder
Meaning
condition
statement_block
Returns
Not applicable
Usage
The While statement is included in Siebel VB for compatibility with older versions
of Basic. The Do...Loop statement is a more general and powerful flow control
statement.
Example
This example opens a series of customer files and checks for the string *Overdue*
in each file. It uses While...Wend to loop through the c:\temP00? files. These files
are created by the subroutine CreateFiles.
(general) (declarations)
Option Explicit
Declare Sub CreateFiles
Sub CreateFiles
Dim odue as String
Dim ontime as String
Dim x
Open "c:\temp001" for OUTPUT as #1
odue = "*Overdue*"
ontime = "*On-Time*"
For x = 1 to 3
Write #1, odue
Next x
For x = 4 to 6
Version 6.0
3-369
See Also
3-370
Version 6.0
Width Statement
This standard VB statement sets the output line width for an open file.
Syntax
Description
filenumber
The file number used in the Open statement to open the file
width
Returns
Not applicable
Usage
A value of zero (0) for width indicates there is no line length limit. The default width
for a file is zero (0).
Example
This example puts five spaces and the string ABCD to a file. The five spaces are
derived by taking 15 Mod 10, or the remainder of dividing 15 by 10.
Sub Button_Click
Dim str1 as String
Dim x as String * 10
str1 = "ABCD"
Open "C:\TEMP001" For Output As #1
Width #1, 10
Print #1, Spc(15); str1
Close #1
Open "c:\temp001" as #1 Len = 12
Get #1, 1,x
Msgbox "The contents of the file is: " & x
Close #1
Kill "c:\temp001"
End Sub
See Also
Version 6.0
3-371
With Statement
With variable
statement_block
End With
Placeholder
Meaning
variable
statement_block
Returns
Not applicable
Usage
3-372
Version 6.0
Example
This example uses a Siebel VB method to change values in an object when a specific
field is successfully changed. With is used to refer to the object in which the values
are changed. For another example, see the Nothing Function on page 3-224.
Sub BusComp_SetFieldValue(FieldName As String)
Select Case FieldName
Case "Account Status"
If Me.GetFieldValue(FieldName) = "Inactive" Then
Dim oBCact as BusComp
Dim sMessage as String
Set oBCact = me.BusObject.GetBusComp("Action")
sMessage = ADDED THRU SVB: Account Status made Inactive"
With oBCact
.NewRecord NewAfter
.SetFieldValue "Type", "Event"
.SetFieldValue "Description", sMessage
.SetFieldValue "Done", _
Format(Now(),"mm/dd/yyyy hh:mm:ss")
.SetFieldValue "Status", "Done"
.WriteRecord
End With
set oBCact = Nothing
End If
End Select
End Sub
See Also
Version 6.0
3-373
Write Statement
Description
filenumber
The file number used in the Open statement to open the file
expressionList
Returns
Not applicable
Usage
The file must be opened in output or append mode. If expressionList is omitted, the
Write statement writes a blank line to the file. (See Input Statement on page 3-158
for more information.)
Example
This example writes a variable to a disk file based on a comparison of its last saved
time and the current time.
Sub Button_Click
Dim tempfile
Dim filetime, curtime
Dim msgtext
Dim acctno(100) as Single
Dim x, I
tempfile = "C:\TEMP001"
Open tempfile For Output As #1
filetime = FileDateTime(tempfile)
x = 1
I = 1
acctno(x) = 0
Do
curtime = Time
acctno(x) = InputBox("Enter an account number (99 to _
end):")
If acctno(x) = 99 then
If x = 1 then Exit Sub
For I = 1 to x-1
Write #1, acctno(I)
3-374
Version 6.0
Next I
Exit Do
ElseIf (Minute(filetime) + 2)< = Minute(curtime) then
For I = I to x-1
Write #1, acctno(I)
Next I
End If
x = x + 1
Loop
Close #1
x = 1
msgtext = "Contents of C:\TEMP001 is:" & Chr(10)
Open tempfile for Input as #1
Do While Eof(1) <> -1
Input #1, acctno(x)
msgtext = msgtext & Chr(10) & acctno(x)
x = x + 1
Loop
MsgBox msgtext
Close #1
Kill "C:\TEMP001"
End Sub
See Also
Close Statement on page 3-45, Open Statement on page 3-238, Print Statement on
page 3-254, and Put Statement on page 3-256
WriteRecord Method
WriteRecord commits to the database any changes made to the current record in a
Siebel business component. For details, see the Siebel Object Interfaces Reference.
Version 6.0
3-375
Year Function
Year(date)
Argument
Description
date
Returns
Usage
Year accepts any type of date, including strings, and will attempt to convert the
input value to a date value.
The return value is a variant of vartype 2 (integer). If the value of date is NULL, a
variant of vartype 1 (Null) is returned.
Example
See Also
3-376
Date Function on page 3-61, Date Statement on page 3-62, DoEvents Statement on
page 3-82, Hour Function on page 3-152, Minute Function on page 3-211, Month
Function on page 3-214, Now Function on page 3-226, Second Function on
page 3-282, Time Function on page 3-343, and WebApplet_InvokeMethod Event on
page 3-366
Version 6.0
Version 6.0
A-1
If you are familiar with older versions of Basic (those that predate Windows), you
will notice that Siebel VB includes many new features and changes from the
language you have learned. Siebel VB more closely resembles other higher level
languages popular today, such as C and Pascal.
The topics below describe some of the differences you will notice between the older
versions of Basic and Siebel VB.
Older versions of Basic require numbers at the beginning of every line. More recent
versions neither support nor require line numbers; in fact, they will generate error
messages.
If you want to reference a line of code, you can use a label. A label can be any
combination of text and numbers. Usually, it is a single word followed by a colon,
which is placed at the beginning of a line of code. These labels are used by the Goto
statement.
A-2
Version 6.0
Variable Scope
Definition
Local
Module
Global
Data Types
Modern Basic is now a typed language. In addition to the standard data types
numeric, string, array, and recordSiebel VB includes variants and objects.
Variables that are defined as variants can store any type of data. For example, the
same variable can hold integers one time, and then, later in a procedure, it can hold
strings.
Objects give you the ability to manipulate complex data supplied by an application,
such as windows, forms, or COM objects.
Financial Functions
Siebel VB includes a list of financial functions for calculating such things as loan
payments, internal rates of return, or future values based on a companys cash
flows.
The date and time functions have been expanded to make it easier to compare a
files date to todays date, set the current date and time, time events, and perform
scheduling-type functions (such as finding the date for next Tuesday).
Version 6.0
A-3
Object Handling
Windows uses the Common Object Model (COM) standard for allowing supported
applications to access one another's functionality. An object is the end product of a
software application, such as a document from a word processing application. An
offshoot of that ability is the Object data type that permits your Siebel VB code to
access another software application through its objects and change those objects.
Environment Control
Siebel VB includes the ability to call another software application (AppActivate) and
send the application keystrokes (SendKeys). Other environment control features
include the ability to run an executable program (Shell), temporarily suspend
processing to allow the operating system to process messages (DoEvents), and
return values in the operating system environment table (Environ).
A-4
Version 6.0
You might be familiar with any of several versions of Basic, the most common being
Visual Basic and Visual Basic for Applications (VBA). Siebel VB shares a substantial
common core of functions and statements with these versions; however, each one
has unique capabilities.
Siebel VB is very similar to Microsofts Visual Basic; however, there are some
differences.
Siebel VB does not provide for the inclusion of any Visual Basic user interface
control objects, such as a Button Control. As a result, a VB property such as
BorderStyle is not an intrinsic part of Siebel VB. Siebel VB enables you to
reference the Siebel user interface controls and to set and retrieve their values. The
Siebel user interface is managed with the Siebel Applet Designer.
Data Types
Siebel VB does not include a Boolean data type. You can simulate a Boolean data
type by using an integer variable and regarding 1 (or any non-zero number) as
TRUE and 0 as FALSE.
NOTE: If you need to call a field of DTYPE_BOOL in a script, you should declare it
as a string.
Version 6.0
A-5
A-6
Version 6.0
Trappable Errors
The following table lists the runtime errors that Siebel VB returns. These errors can
be trapped by On Error. The Err function can be used to query the error code, and
the Error function can be used to query the error text.
Table B-1.
Error code
Version 6.0
(Sheet 1 of 3)
Error Text
Overflow
Out of memory
10
Duplicate definition
11
Division by zero
13
Type Mismatch
14
19
No Resume
20
28
35
48
52
53
54
B-1
Trappable Errors
About This Appendix
Table B-1.
Error code
B-2
(Sheet 2 of 3)
Error Text
55
58
61
Disk full
62
63
64
68
Device unavailable
70
Permission denied
71
74
75
76
91
93
Invalid pattern
94
102
Command failed
429
438
439
440
Object error
901
902
903
904
Version 6.0
Trappable Errors
About This Appendix
Table B-1.
Error code
Version 6.0
(Sheet 3 of 3)
Error Text
905
906
907
Pushbutton required
908
910
B-3
Trappable Errors
About This Appendix
B-4
Version 6.0
Version 6.0
(Sheet 1 of 2)
Function
Computed By
Secant
Sec(x) = 1/Cos(x)
CoSecant
CoSec(x) = 1/Sin(x)
CoTangent
CoTan(x) = 1/Tan(x)
ArcSine
ArcSin(x) = Atn(x/Sqr(-x*x+1))
ArcCosine
ArcCos(x) = Atn(-x/Sqr(-x*x+1))+1.5708
ArcSecant
ArcSec(x) = Atn(x/Sqr(x*x-1))+Sgn(x-1)*1.5708
ArcCoSecant
ArcCoSec(x) = Atn(x/Sqr(x*x-1))+(Sgn(x)-1)*1.5708
ArcCoTangent
ArcTan(x) = Atn(x)+1.5708
Hyperbolic Sine
HSin(x) = (Exp(x)-Exp(-x))/2
Hyperbolic Cosine
HCos(x) = (Exp(x)+Exp(-x))/2
Hyperbolic Tangent
HTan(x) = (Exp(x)-Exp(-x))/(Exp(x)+Exp(-x))
Hyperbolic Secant
HSec(x) = 2/(Exp(x)+Exp(-x))
Hyperbolic CoSecant
HCoSec(x) = 2/(Exp(x)-Exp(-x))
Hyperbolic Cotangent
Hyperbolic ArcSine
HArcSin(x) = Log(x+Sqr(x*x+1))
Hyperbolic ArcCosine
HArcCos(x) = Log(x+Sqr(x*x-1))
Hyperbolic ArcTangent
HArcTan(x) = Log((1+x)/(1-x))/2
C-1
Table C-1.
C- 2
(Sheet 2 of 2)
Function
Computed By
Hyperbolic ArcSecant
HArcSec(x) = Log((Sqr(-x*x+1)+1)/x)
Hyperbolic ArcCoSecant
HArcCoSec(x) = Log((Sgn(x)*Sqr(x*x+1)+1)/x)
Hyperbolic ArcCoTangent
HArcCoTan(x) = Log((x+1)/(x-1))/2
Version 6.0
Glossary
call by reference
call by value
comment
control ID
This can be either a text string, in which case it is the name of the control,
or it can be a numeric ID. Note that control IDs are case-sensitive and do
not include the dot that appears before the ID. Numeric IDs depend on the
order in which dialog controls are defined. You can find the numeric ID
using the DlgControlID function.
function
Version 6.0
Glossary
label
metacommand
name
A Basic name must start with a letter (A through Z). The remaining part of
a name can also contain numeric digits (0 through 9) or an underscore
character (_). A name cannot be more than 40 characters in length. Type
characters are not considered part of a name.
precedence order
procedure
subprogram
vartype
The internal tag used to identify the type of value currently assigned to a
variant. One of the following:
Empty
Null
Integer
Long
Single
Double
Currency
Date
String
Object
Version 6.0
Index
A
Abs function 3-16
absolute value of a number, calculating 3-16
access to files 3-198
activity record, adding 3-225
AND operator 2-20
angles
cosine, calculating 3-49
sine, calculating 3-304
tangent, calculating 3-341
ANSI code, changing to string
characters 3-22
AppActivate Statement 3-19
Applet_InvokeMethod event 3-366
Applet_PreInvokeMethod event 3-366
application window, activating 3-19
arccosecant, calculating C-1
arccosine, calculating C-1
arccotangent, calculating C-1
arcsecant, calculating C-1
arcsine, calculating C-1
arctangent angle, calculating 3-23
arguments
See also named arguments
Help syntax Intro-6
passing 3-30
programming conventions 2-82-9
querying callers for a procedure 3-177
array data types 2-11
arrays
declaring 3-145
dynamic 2-162-17
lower bound of subscript range 3-185
resizing when full of data 3-243
statements, list of 1-2
Version 6.0
B
Basic programming language, previous
versions A-2A-4
Beep statement 3-24
ByVal keyword 3-30, 3-69
C
Call statement 3-29
calling procedure, transferring control
to 3-98
case-sensitivity 3-244
cash flows, constant periodic stream 3-258
CCur function 3-32
CDbl function 3-34
characters, as literal characters 3-292
ChDir statement 3-35
ChDrive statement 3-37
Chr function 3-38
CInt function 3-40
Clipboard methods 3-42
CLng function 3-44
clock, setting system 3-346
Close statement 3-45
code, identifying as a comment 3-266
COM automation objects
access 3-231
creating 3-50
Index
COM objects
assigning to a variable 3-295
associated with a file or application 3-139
comments, programming conventions 2-10
comparison operators 2-19
compiler directives 1-2
connections
queries on 3-322
storing queries in a file 3-325
Const statement 3-47
control flow, statements 1-3
control, transferring to a subprogram or
function 3-29
control-based objects, Siebel VB and
previous Basic differences A-5
controls
rendering on a web page 3-366
conventions
See also programming conventions
typographic Intro-6
conversions 2-15
Cos function 3-49
cosecant, calculating C-1
cosine, calculating 3-49
cotangent, calculating C-1
CreateObject function 3-50
CSng function 3-52
CStr function 3-54
CurDir function 3-56
currency data type, converting to 3-32
current date 3-61, 3-226
current time 3-226
current user ID, returning 3-314
CVar function 3-58
CVDate function 3-59
D
data source information, returning 3-314
data sources, connecting to 3-320
data types
about 2-11
array 2-11
conversions 2-15
currency 3-32
declaring 3-75
default, specifying for one or more
variables 3-71
double 3-34
in Siebel VB A-5
integer 3-40
long 3-44
numeric 2-12
record 2-13
Siebel VB and previous Basic
differences A-3
single 3-52
string 2-13, 3-54
variant 2-17, 3-58, 3-59
databases, query warning 3-315
Date function 3-61
Date statement 3-62
dates
confirming 3-174
current 3-226
formatting 3-1203-123
Siebel VB and previous Basic
differences A-3
statements, list of 1-4
DateSerial function 3-64
date-time value
day component 3-367
month component 3-214
year component 3-376
DateValue function 3-65
day component of a date-time value 3-367
Day function 3-67
debugging 3-246
declarations, statements 1-5
Declare statement 3-68
declaring variables 3-246
default directory
changing 3-35
returning 3-56
default drive
changing 3-37
returning 3-56
Version 6.0
Index
E
elapsed time 3-347
end of file 3-86
Environ function 3-84
environment table, keywords in 3-84
environmental control
Siebel VB and previous Basic
differences A-4
statements, list of 1-6
Eof function 3-86
EQV operator 2-20
Erase statement 3-88
Erl function 3-90
Version 6.0
F
factorials, calculating 3-52, 3-99
file control statements 1-7
file input/output statements 1-8
file mode, returning 3-101
file number, lowest unused 3-126
FileAttr function 3-101
FileCopy statement 3-103
FileDateTime function 3-105
FileLen function 3-107
filename, returning 3-79
files
access 3-198, 3-361
atrributes, returning 3-135
attributes, setting 3-297
attributes, testing 3-290
Index
closing 3-45
closing an open file 3-102
closing open 3-269
copying 3-103
current position 3-284
deleting from a hard disk or floppy 3-183
end, determining 3-86
length 3-200
length, returning 3-107
locking 3-198
modification date and time 3-105
opening 3-238
position for read/write operations 3-286
printing to screen 3-200
renaming 3-220
sharing 3-198
financial functions
Siebel VB and previous Basic
differences A-3
statements 1-9
Fix function 3-109
fixed array, reinitializing the contents 3-88
fixed-length string variables, declaring 3-77,
3-146
For...Next statement 3-98, 3-111
Format function 3-114
formatting
dates and times 3-1203-123
numbers 3-1153-119
strings 3-1233-125
FreeFile function 3-126
function keys 3-293
function procedure, defining 3-1273-129
Function...End Function statement 3-127
functions
Help syntax Intro-6
Siebel VB and previous Basic
differences A-5
future value 3-131
FV function 3-130
G
Get statement 3-132
GetAttr function 3-135
GetLastErrText method 2-28
GetObject function 3-139
Global statement 3-144
Global variables, declaring 3-144
GoTo statement 3-148, 3-149
H
Hex function 3-151
hexadecimals 3-151
hour component of a date-time value 3-152
Hour function 3-152
hyperbolic arccosecant, calculating C-2
hyperbolic arccosine, calculating C-1
hyperbolic arccotangent, calculating C-2
hyperbolic arcsecant, calculating C-2
hyperbolic arcsine, calculating C-1
hyperbolic arctangent, calculating C-1
hyperbolic cosecant, calculating C-1
hyperbolic cosine, calculating C-1
hyperbolic cotangent, calculating C-1
hyperbolic secant, calculating C-1
hyperbolic sine, calculating C-1
hyperbolic tangent, calculating C-1
I
If...Then...Else statement 3-154
IMP operator 2-20
Input function 3-156
Input statement 3-158
input/output, concluding 3-45
InputBox function 3-160
instantiation 3-355
InStr function 3-163
Int function 3-166
integer data type, converting to 3-40
integer part of a number, returning 3-166
interest payments, calculating 3-169
interest rates, calculating 3-261
investment, present value of 3-227
Version 6.0
Index
K
keystrokes, sending to an application 3-291
keywords, non-printable 3-292
Kill statement 3-183
L
labels, Siebel VB and previous Basic
differences A-2
LBound function 3-185
LCase function 3-187
Left function 3-188
legal date, confirming 3-174
Len function 3-190
Let (Assignment statement) 3-191
Like operator 3-193
Line Input statement 3-195
line numbers, Siebel VB and previous Basic
differences A-2
list columns
rendering on a web page 3-366
loan payments, converting to a currency
value 3-33
Loc function 3-197
Lock statement 3-198
Lof function 3-200
Log function 3-201
logarithms 3-201
logical operators 2-20
long data type, converting to 3-44
looping
Do...Loop statement 3-81, 3-98
For...Next statement 3-98, 3-111
loop statements, terminating 3-98
While...Wend statement 3-369
Version 6.0
lower bound
changing 3-263
default, specifying 3-241
lowercase strings 3-187
Lset statement 3-203
LTrim function 3-205
M
math functions, statements 1-91-10
Me 3-206
Me object reference 2-6
message dialog box 3-216
methods, handling 2-21
Microsoft Excel 3-50
Microsoft Visual Basic compared to Siebel
VB A-5
Microsoft Word documents, creating 3-51
Mid function 3-207
Mid statement 3-209
minute component of a date value 3-211
Minute function 3-211
MkDir statement 3-213
modularity, language A-2
Modulus operator 2-19
month component of a date-time
value 3-214
Month function 3-214
Msgbox function 3-216
N
Name statement 3-220
named arguments
in Call statements 3-29
procedures 3-30
programming conventions 2-92-10
naming conventions for code 2-5
negative numbers 3-301
New operator 3-222
non-printable keys 3-292
NOT operator 2-20
Nothing function 3-224
Now function 3-226
NPV function 3-227
Index
O
Object class 3-231
object handling
described 2-212-23
Siebel VB and previous Basic
differences A-4
object variables, declaring 3-76
objects
class, determining 3-356
COM-compliant 2-22
current 3-206
defined 2-21
instantiated, removing 3-224
instantiating 2-21
Siebel, instantiating 3-295
statements 1-10
using 2-21
Oct function 3-233
octal numbers 3-233
ODBC data source
connecting to 3-317
disconnecting from 3-308
ODBC function call errors in 3-310
ODBC statements 1-11
On Error statement 2-25, 3-98, 3-235
On...Goto statement 3-234
one-character string, returning 3-38
P
payments
constant periodic, calculating 3-249
principal portion 3-252
Pmt function 3-249
positive numbers 3-301
PPmt function 3-252
present value, calculating 3-259
print position, moving to a column 3-339
Print statement 3-254
printing
to a file 3-254
to screen 3-157, 3-254
spaces 3-306
program execution, stopping 3-330
programming conventions 2-82-10
properties, handling 2-21
Put statement 3-256
PV function 3-258
R
Random access 3-257
random number generator 3-260
random numbers 3-277
Randomizestatement 3-260
Rate function 3-261
rate of return, calculating 3-171
record data types 2-13
record variables, declaring 3-76, 3-145
ReDim statement 2-11, 2-16, 3-263
Rem statement 3-266
Version 6.0
Index
S
sappsrv.tlb 2-3
secant, calculating C-1
second component of a time value 3-282
Second function 3-282
Seek function 3-284
Seek statement 3-286
Select Case statement 3-288
SendKeys statement 3-291
Set statement 3-295
SetAttr statement 3-297
Sgn function 3-301
Shell function 3-302
Siebel BusObject interfaces 2-3
Siebel COM Automation Server,
accessing 2-3
Siebel objects, instantiating 3-295
Siebel Visual Basic
compared to Microsoft Visual Basic A-5
compared to previous versions of
Basic A-2A-4
error, simulating 3-96
features Intro-2
getting started 2-5
Me object reference 2-6
and older Basic, version differences A-2
Version 6.0
Index
string variables
copying 3-203
from a sequential file 3-195
strings
comparing 3-244, 3-332
comparing contents 3-193
copying from another string 3-188
copyingf 3-281
end of string portion 3-273
formatting 3-1233-125
identifying a portion 3-207
length 3-190
lowercase to uppercase 3-359
numeric value of first number 3-362
repeating characters 3-334
replacing 3-209
right-aligning 3-279
spaces 3-305
statements 1-12
trailing spaces 3-353
trailing spaces, removing 3-281
Sub...End Sub statement 3-336
subprogram procedure 3-336
subroutines, Siebel VB and previous Basic
differences A-2
symbolic constants, declaring 3-47
system date, setting 3-62
system time, setting 3-345
T
Tab function 3-339
table columns, returning 3-314
table names, returning 3-314
Tan function 3-341
tangent, calculating 3-341
task ID of a Windows application 3-302
Technical Support Intro-8
time
as a variant 3-349
current 3-226
cururent 3-343
elapsed 3-347
formatting 3-1203-123
Siebel VB and previous Basic
differences A-3
system, setting 3-345
Time function 3-343
Time statement 3-345
time value
hour component 3-152
minute component 3-211
returning 3-350
second component 3-282
Timer function 3-347
times statements, list of 1-4
TimeSerial function 3-349
TimeValue function 3-350
To keyword 3-289
trailing spaces, removing 3-281
trapping errors
generated by Siebel VB methods 2-28
line number 3-90
list B-1B-3
returned by Siebel VB 2-242-25
run-time error code 3-91
user-defined errors 2-262-27
trigonometric functions
derived C-1C-2
statements 1-10
Trim function 3-353
type characters 2-14
Type statement 3-354
type, user-defined 3-354
Typeof function 3-356
typographic conventions Intro-6
U
UBound function 3-357
UCase function 3-359
Unlock statement 3-361
upper bound, changing 3-263
user interface A-5
user-defined error, simulating 3-96
Version 6.0
Index
V
Val function 3-362
value on an investment 3-227
value, future 3-130
variable scope 3-74, A-3
variables
declared, specifying 3-246
declaring 2-5, 3-232
declaring and storing 3-328
declaring for use in a Basic program 3-73
determining value 3-181
finding differences between 3-16
naming conventions for 2-5
specifying the default data type 3-71
writing to a file opened in random or
binary mode 3-256
variant data type
about 2-17
converting to 3-58, 3-59
variants
conversions 2-15
declaring 3-146
declaring variables as 3-77
initialization, determining 3-175
list 1-13
Version 6.0
W
Weekday function 3-367
While...Wend statement 3-369
Width statement 3-371
Windows applications, starting and task
ID 3-302
Windows Clipboard 3-42
With statement 3-372
Write statement 3-374
writing data to a file 3-374
X
XOR operator 2-20
Y
year component of a date-time value 3-376
Year function 3-376
Index
10
Version 6.0