0% found this document useful (0 votes)
488 views468 pages

Iebel Usiness Pplications: S VBL R

Siebel, the Siebel logo, ActiveBriefing, TrickleSync, TSQ, Universal Agent, and other Siebel product names referenced herein are trademarks of Siebel Systems, Inc. All other product names, marks, logos, and symbols may be trademarks or registered trademarks of their respective owners. Siebel eBusiness Applications includes technology used under license from Fulcrum Technologies, Inc.

Uploaded by

sorelyn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
488 views468 pages

Iebel Usiness Pplications: S VBL R

Siebel, the Siebel logo, ActiveBriefing, TrickleSync, TSQ, Universal Agent, and other Siebel product names referenced herein are trademarks of Siebel Systems, Inc. All other product names, marks, logos, and symbols may be trademarks or registered trademarks of their respective owners. Siebel eBusiness Applications includes technology used under license from Fulcrum Technologies, Inc.

Uploaded by

sorelyn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 468

SIEBEL eBUSINESS APPLICATIONS

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.

Siebel VB Language Reference

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

Contacting Siebel Technical Support . . . . . . . . . . . . . . . . . . . . . . . . Intro-8


Siebel Welcomes Your Comments . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-9

Chapter 1. Quick Reference: Statements and Functions


About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Dates & Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Environment Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Disk and Directory Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
File Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
File Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8

Version 6.0

Siebel VB Language Reference

iii

Contents

Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9


Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1-10
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
String Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Variants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13

Chapter 2. Language Overview


Setting Up Microsoft Visual Basic to Access the Siebel Applications . . . . 2-3
Getting Started with Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Named Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-10
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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

iv

Siebel VB Language Reference

Version 6.0

Contents

Comparison Operators (Numeric and String) . . . . . . . . . . . . . . . . . . . . . .2-19


Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-20
Object Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Step 1: Create an Object Variable to Access the Object . . . . . . . . . . . . . . . 2-23
Step 2: Use Methods and Properties to Act on Objects . . . . . . . . . . . . . . .2-23
Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Trapping Errors Returned by Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Option 1: Trap Errors Within Body of Code . . . . . . . . . . . . . . . . . . . . . . .2-25
Option 2: Trap Errors Using an Error Handler . . . . . . . . . . . . . . . . . . . . . .2-25
Trapping User-Defined (Non-Siebel VB) Errors . . . . . . . . . . . . . . . . . . 2-26
Trapping Errors Generated by Siebel VB Methods

. . . . . . . . . . . . . . . . 2-28

Chapter 3. Siebel VB Language Reference


About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Abs Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
ActivateField Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveBusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveViewName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AddChild Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AllowNotification Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AppActivate Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Applet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_GotFocus Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_Load Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_LostFocus Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20

Version 6.0

Siebel VB Language Reference

Contents

Applet_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21


Application_Close Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_PreClose Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_Start Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Asc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Associate Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Atn Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Beep Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
BusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_Associate Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_ChangeRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_CopyRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_DeleteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_NewRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreAssociate Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreCopyRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreDeleteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreGetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreInvokeMethod Event

. . . . . . . . . . . . . . . . . . . . . . . . . . 3-27

BusComp_PreNewRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27


BusComp_PreQuery Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreSetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreWriteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
BusComp_Query Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
BusComp_SetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

vi

Siebel VB Language Reference

Version 6.0

Contents

BusComp_WriteRecord Event

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

BusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28


Call Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
CCur Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
CDbl Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
ChDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-35
ChDrive Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Chr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-38
CInt Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40

ClearToQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-41


Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
CLng Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Close Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
Const Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
Copy Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
Cos Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
CreateObject Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
CSng Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
CStr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-54
CurDir Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56
CurrencyCode Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-57
CVar Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58
CVDate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
Date Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Date Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-62
DateSerial Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64
DateValue Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-65
Day Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67

Version 6.0

Siebel VB Language Reference

vii

Contents

DeactivateFields Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67

Declare Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68


Deftype Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-71
DeleteRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Dim Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73

Dir Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79


Do...Loop Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-81
DoEvents Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-82
Drilldown Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-83
Environ Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-84
Eof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
Erase Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-88
Erl Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-90
Err Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-91
Err Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-92
Error Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-94
Error Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-96
ExecuteQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97
ExecuteQuery2 Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97

Exit Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-98


Exp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-99
FileAttr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-101
FileCopy Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-103
FileDateTime Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-105
FileLen Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-107
FindActiveXControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FindApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FindControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108

vii i

Siebel VB Language Reference

Version 6.0

Contents

FirstRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108


FirstSelected Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
Fix Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-109
For...Next Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-111
Format Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-114
FreeFile Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-126
Function...End Function Statement . . . . . . . . . . . . . . . . . . . . . . . . . 3-127
FV Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-130
Get Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-132
GetAssocBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-134
GetAttr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-135
GetBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetBusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetChild Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetChildCount Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetFirstProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetFormattedFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetMVGBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetNamedSearch Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetNextProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetObject Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-139
GetPicklistBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-141
GetProfileAttr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-141
GetProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetSearchExpr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetSearchSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetService Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142

Version 6.0

Siebel VB Language Reference

ix

Contents

GetSharedGlobal Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142


GetType Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
GetUserProperty Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143

GetValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143


GetViewMode Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
Global Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-144
GoTo Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-148
GotoApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150
GotoControl Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150

GotoView Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150


Hex Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-151
Hour Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-152
If...Then...Else Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-154
Input Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-156

Input Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-158


InputBox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-160
InputBox Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-162
InsertChildAt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-162
InStr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-163
Int Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-166
InvokeMethod Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-168
IPmt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-169
IRR Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-171
Is Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-173
IsDate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-174
IsEmpty Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-175

IsMissing Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-177


IsNull Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-179

Siebel VB Language Reference

Version 6.0

Contents

IsNumeric Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-181


Kill Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-183
LastRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-184
LBound Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-185
LCase Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-187
Left Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-188
Len Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-190
Let (Assignment Statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-191
Like Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-193
Line Input Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-195
Loc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-197
Lock Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-198
Lof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-200
Log Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-201
LoginId Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-202
LoginName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-202
Lset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-203
LTrim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-205
Me . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-206
Mid Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-207
Mid Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-209
Minute Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-211

MkDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-213


Month Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-214
Msgbox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-216
MsgBox Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-219
Name Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-219
Name Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-220

Version 6.0

Siebel VB Language Reference

xi

Contents

New Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-222


NewPropertySet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NewRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NextRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NextSelected Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
Nothing Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-224
Now Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-226
NPV Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-227
Null Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-229
Object Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-231
Oct Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-233
On...GoTo Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-234
On Error Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-235
Open Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-238
Option Base Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-241
Option Compare Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-244
Option Explicit Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-246
ParentBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-248
Pick Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-248
Pmt Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-249

PositionId Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251


PositionName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251
PostChanges Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251
PPmt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-252
PreviousRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-253
Print Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-254
PropertyExists Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-255
Put Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-256

xii

Siebel VB Language Reference

Version 6.0

Contents

PV Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-258

Randomize Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-260


Rate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-261
ReDim Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-263
RefineQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-265
Rem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-266
RemoveChild() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268
RemoveProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268
Reset Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268
Reset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-269
Resume Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-271
Right Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-273
RmDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-275
Rnd Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-277
Rset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-279
RTrim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-281
Second Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-282
Seek Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-284
Seek Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-286
Select Case Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-288
SendKeys Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-291
Service_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-294
Service_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-294
Set Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-295
SetAttr Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-297
SetFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetFormattedFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetNamedSearch Method

Version 6.0

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298

Siebel VB Language Reference

x iii

Contents

SetProfileAttr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298


SetProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetSearchExpr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSearchSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSharedGlobal Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSortSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetType Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetUserProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300
SetValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300
SetViewMode Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300

Sgn Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-301


Shell Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-302
ShowStatus Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-303
Sin Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-304
Space Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-305
Spc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-306
SQLClose Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-308
SQLError Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-310
SQLExecQuery Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-312
SQLGetSchema Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-314
SQLOpen Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-317
SQLRequest Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-320
SQLRetrieve Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-322
SQLRetrieveToFile Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-325
Sqr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-327
Static Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-328

Stop Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-330


Str Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-331

xiv

Siebel VB Language Reference

Version 6.0

Contents

StrComp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-332


String Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-334
Sub...End Sub Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-336
SuppressNotification Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-338
Tab Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-339
Tan Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-341
theApplication Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-342
Time Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-343
Time Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-345
Timer Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-347
TimeSerial Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-349
TimeValue Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-350
Trace Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
TraceOff Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
TraceOn Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
Trim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-353
Type Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-354
Typeof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-356
UBound Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-357
UCase Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-359
UndoRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-360
Unlock Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-361
Val Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-362
VarType Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-363
WebApplet_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-366
WebApplet_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-366
WebApplet_ShowControl Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-366
WebApplet_ShowListColumn Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-366

Version 6.0

Siebel VB Language Reference

xv

Contents

Weekday Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-367


While...Wend Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-369
Width Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-371
With Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-372
Write Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-374
WriteRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-375
Year Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-376

Appendix A. How Siebel VB Compares to


Other Versions of Basic
Differences Between Siebel VB and Earlier Versions of Basic . . . . . . . . . A-2
Line Numbers and Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
Subroutines and Modularity of the Language . . . . . . . . . . . . . . . . . . . . . . A-2
Variable Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Date and Time Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Object Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Environment Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Differences Between Siebel VB and Visual Basic . . . . . . . . . . . . . . . . . . A-5
User Interface and Control-Based Objects . . . . . . . . . . . . . . . . . . . . . . . . . A-5
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5

Appendix B. Trappable Errors


Appendix C. Derived Trigonometric Functions
Glossary
Index

xvi

Siebel VB Language Reference

Version 6.0

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

Contacting Siebel Technical Support . . . . . . . . . . . . . . . . . . . . . . . . Intro-8


Siebel Welcomes Your Comments . . . . . . . . . . . . . . . . . . . . . . . . . . Intro-9

Version 6.0

Siebel VB Language Reference

I n tr o - 1

Introduction
Welcome to Siebel VB

Welcome to Siebel VB

Intro

Siebel VB is an enhanced configuration environment which includes:

 A fully functional procedural programming language


 A bidirectional application interface to provide bidirectional access to Siebel
Business Objects

 An editing environment to create and maintain custom Siebel VB routines


 A debugger to assist in detecting errors in Siebel VB routines
 A compiler to compile the custom Siebel VB routines
 A run-time engine (similar to a Basic interpreter) to process the custom Siebel
VB routines
You will find it easy to use Siebel VB to create scripts that automate a variety of daily
tasks.
Siebel VB runs on the following Siebel platforms:

 Siebel dedicated client


 Siebel mobile client
 The Siebel Object Manager running on Windows NT and Windows 2000
Developers looking for scripting functionality on their Unix-hosted Siebel Object
Manager should refer to the Siebel eScript Language Reference. HTML and Windows
Thin Client developers looking for client-side scripting capabilities outside the
Siebel development environment should consult reference materials that describe
the scripting capabilities of the browsers employed by end-users.

In t ro - 2

Siebel VB Language Reference

Version 6.0

Introduction
Who Should Use This Guide

Who Should Use This Guide

Intro

The audience for this guide consists of:


Siebel Application
Developers

Persons who plan, implement, and configure Siebel applications,


possibly adding new functionality. A developer is typically
someone from the Information Services department.

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

Siebel VB Language Reference

I n tr o - 3

Introduction
Supported Uses of Siebel VB

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:

 Siebel VB language to behave as documented


 Siebel Tools to allow creation, modification, and deletion of Siebel VB scripts as
documented in the Siebel Object Interfaces Reference
Siebel does not support:

 Functionality developed through custom programming


 Automatic upgrades of custom routines with the Siebel Application Upgrader
 Development of separate, standalone applications with Siebel VB
 Accessing server management functions through Siebel VB; such functions
should be accessed only through the UI or the command line

In t ro - 4

Siebel VB Language Reference

Version 6.0

Introduction
How This Guide Is Organized

How This Guide Is Organized

Intro

This guide is divided into the following sections.


The Quick Reference: Statements and Functions offers a summary of all the
commands and functions, divided into functional areas. It also contains brief
descriptions of each command and function.
The Language Overview describes the essential rules and components of Siebel VB.
The Siebel VB Language Reference contains a full listing of every command and
function, including examples, in Siebel VB. It also contains a cross-reference to all
the Siebel VB methods described in the Siebel Object Interfaces Reference, in
alphabetical order.
The Appendices provide information about trappable error codes and derived
trigonometric functions, and comparisons between Siebel VB and other versions of
Basic.

Version 6.0

Siebel VB Language Reference

I n tr o - 5

Introduction
Typographic Conventions

Typographic Conventions

Intro

This guide uses the following typographic conventions.


Table 1.

Typographic Conventions

To Represent

Help Syntax Is

Statements and functions

Initial letter uppercase: Abs Len(variable)

Arguments to statements or
functions

All lowercase, italicized letters; an internal capital may


be used to indicate multiple English words:
variable, rate, prompt, sringVar

Optional arguments and/or


characters

Arguments and/or characters in brackets:

Required choice for an


argument from a list of choices

A list inside braces, with OR operator ( | ) separating


choices:

[, caption], [type], [$]

{Goto label | Resume Next | Goto 0}

In t ro - 6

Siebel VB Language Reference

Version 6.0

Introduction
Additional Documentation

Additional Documentation

Intro

The following documentation also provides information on the topics addressed in


this guide.
Siebel Tools Guide
Siebel Object Interfaces Reference
The Siebel Tools Guide explains all the functionality of Siebel Tools, the primary
means of customizing your Siebel applications. In general, VB programming should
be undertaken only when Siebel Tools cannot provide the functionality you require;
custom code may not function properly after an upgrade, but anything created
directly using Siebel Tools will be supported.
The Siebel Object Interfaces Reference provides information on using the
programming environment built into Siebel Tools, and also contains complete
documentation on the specialized Siebel VB methods and event handlers designed
to facilitate program development and interfacing to Siebel objects.
You will find information about Siebel Technical and Professional Services in the
Guide to Siebel Services.
For copies of these documents, please use Siebel Books Online, accessible via the
Worldwide Services tab on the Siebel Systems Web site (www.siebel.com). Through
Siebel Books Online, you can order additional Siebel documentation and copies of
the Bookshelf for Siebel Enterprise Applications CD-ROM.
Another source of information is the Siebel Online Help.

Version 6.0

Siebel VB Language Reference

I n tr o - 7

Introduction
Contacting Siebel Technical Support

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:

 You must attend Siebel training to become a designated contact.


 Your trained designated contacts provide technical support to your users. Siebel
Technical Support provides support to your designated contacts only.
To provide efficient and timely support, and to empower you in the process:

 Siebel Technical Support is primarily Web-based, accessed via Siebel


SupportWeb (http://supportweb.siebel.com). Please submit new service
requests to us through SupportWeb, where you can also search the knowledge
base for solutions.

 Designated contacts receive read/write access to SupportWeb. All other project


team members at your company receive a read-only account to ensure they can
reap the benefits of the support knowledge base.
To register for Siebel training, please access http://www.siebel.com/education/ and
choose Siebel Customer Technical Education. Questions on the above can be
directed to Siebel Technical Support at:
Enterprise Customers: [email protected]
Workgroup Customers: [email protected] or:
Americas: Enterprise: 800.214.0400 or 650.295.5724 Workgroup: 800.354.1571
London:

+44.1784.494.949

Tokyo:

+81.3.5469.3811(main number)

Munich:

+49.89.95718.400

Singapore: +65.320.8533 (main number)

Please submit technical issues and updates to Siebel SupportWeb


(http://supportweb.siebel.com). If you do not have a SupportWeb account, please
email us at the relevant e-mail address above. Thank you and we hope you enjoy
working with Siebel Technical Support!

In t ro - 8

Siebel VB Language Reference

Version 6.0

Introduction
Siebel Welcomes Your Comments

Siebel Welcomes Your Comments

Intro

To help us with future versions, we want to know about any corrections or


clarifications that you would find useful. Please include in your message:

 The title and version of this guide


 Your name, your company name, job title or functional area, phone number, and
email address
Write to us via regular mail or e-mail at:
Siebel Systems, Inc.
Technical Publications Department
1855 South Grant Street
San Mateo, CA 94402-2667
[email protected]
We appreciate your feedback.

Version 6.0

Siebel VB Language Reference

I n tr o - 9

Introduction
Siebel Welcomes Your Comments

In t ro - 1 0

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions

About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2


Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Dates & Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Environment Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Disk and Directory Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
File Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
File Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
String Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Variants

Version 6.0

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13

Siebel VB Language Reference

1-1

Quick Reference: Statements and Functions


About This Chapter

About This Chapter

This chapter lists the Siebel VB statements and functions by functional group.

Arrays

Statement

Function

Erase

Re-initializes the contents of an array

LBound

Returns the lower bound of an arrays dimension

ReDim

Declares dynamic arrays and reallocates memory

UBound

Returns the upper bound of an arrays dimension

Compiler Directives

1-2

Statement

Function

Rem

Treats the remainder of the line as a comment

'

Treats the remainder of the line as a comment

Treats the next line as a continuation of the current line

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


Control Flow

Control Flow

Version 6.0

Statement

Function

Call

Transfers control to a subprogram

Do...Loop

Controls repetitive actions

Exit

Causes the current procedure or loop structure to return

For...Next

Loops a fixed number of times

Goto

Sends control to a line label

If...Then...Else

Branches on a conditional value

Let

Assigns a value to a variable

Lset

Left-aligns one string or a user-defined variable within another

On...Goto

Branches to one of several labels depending upon value

Rset

Right-aligns one string or a user-defined variable within another

Select Case

Executes one of a series of statement blocks

Set

Sets an object variable to a value

Stop

Stops program execution

While...Wend

Controls repetitive actions

With

Executes a series of statements on a specified variable or object

Siebel VB Language Reference

1-3

Quick Reference: Statements and Functions


Dates & Times

Dates & Times

1-4

Statement

Function

Date Function

Returns the current date

Date Statement

Sets the system date

DateSerial

Returns the date value for year, month, and day specified

DateValue

Returns the date value for string specified

Day

Returns the day of month component of a date-time value

Hour

Returns the hour of day component of a date-time value

IsDate

Determines whether a value is a legal date

Minute

Returns the minute component of a date-time value

Month

Returns the month component of a date-time value

Now

Returns the current date and time

Second

Returns the second component of a date-time value

Time Function

Returns the current time

Time Statement

Sets the current time

Timer

Returns the number of seconds since midnight

TimeSerial

Returns the time value for hour, minute, and second specified

TimeValue

Returns the time value for string specified

Weekday

Returns the day of the week for the specified date-time value

Year

Returns the year component of a date-time value

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


Declarations

Declarations

Version 6.0

Statement

Function

Const

Declares a symbolic constant

Declare

Forward declares a procedure in the same module or in a


dynamic link library

Deftype

Declares the default data type for variables

Dim

Declares variables

Function...End Function

Defines a function

Global

Declares a global variable

Option Base

Declares the default lower bound for array dimensions

Option Compares

Declares the default case sensitivity for string comparisons

Option Explicit

Forces all variables to be declared explicitly

ReDim

Declares dynamic arrays and reallocates memory

Static

Defines a static variable or subprogram

Sub ... End Sub

Defines a subprogram

Type

Declares a user-defined data type

Siebel VB Language Reference

1-5

Quick Reference: Statements and Functions


Environment Control

Environment Control

Statement

Function

AppActivate

Activates another application

Command

Returns the command line specified when the MAIN sub was run

Beep

Makes a sound through the computers speaker

Date Statement

Sets the current date

DoEvents

Lets the operating system process messages

Environ

Returns a string from the operating systems environment

Randomize

Initializes the random-number generator

SendKeys

Sends keystrokes to another application

Shell

Runs an executable program

Errors

1-6

Statement

Function

Erl

Returns the line number where a run-time error occurred

Err Function

Returns a run-time error code

Err Statement

Sets the run-time error code

Error Statement

Generates an error condition

Error Function

Returns a string representing an error

On Error

Controls run-time error handling

Resume

Ends an error-handling routine

Trappable Errors

Errors that can be trapped by Siebel VB code

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


Files

Files

Disk and Directory Control

Statement

Function

ChDir

Changes the default directory for a drive

ChDrive

Changes the default drive

CurDir

Returns the current directory for a drive

Dir

Returns a filename that matches a pattern

MkDir

Creates a directory on a disk

RmDir

Removes a directory from a disk

File Control

Version 6.0

Statement

Function

FileAttr

Returns information about an open file

Felicity

Copies a file

FileDateTime

Returns the modification date and time of a specified file

FileLen

Returns the length of specified file in bytes

GetAttr

Returns attributes of specified file, directory, or volume


label

Kill

Deletes files from a disk

Name

Renames a disk file

SetAttr

Sets attribute information for a file

Siebel VB Language Reference

1-7

Quick Reference: Statements and Functions


Files

File Input/Output

1-8

Statement

Function

Close

Closes a file

Eof

Checks for end of file

FreeFile

Returns the next unused file number

Get

Reads bytes from a file

Input Function

Returns a string of characters from a file

Input Statement

Reads data from a file or from the keyboard

Line Input

Reads a line from a sequential file

Loc

Returns the current position in an open file

Lock

Controls access to some or all of an open file by other processes

Lof

Returns the length of an open file

Open

Opens a disk file for I/O

Print

Prints data to a file or to the screen

Put

Writes data to an open file

Reset

Closes all open disk files

Seek Function

Returns the current position for a file

Seek Statement

Sets the current position for a file

Spc

Outputs a given number of spaces

Tab

Moves the print position to the given column

Unlock

Controls access to some or all of an open file by other processes

Width

Sets the output-line width for an open file

Writes

Writes data to a sequential file

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


Math Functions

Math Functions

Financial Functions

Statement

Function

FV

Returns future value of a cash flow stream

IPmt

Returns interest payment for a given period

IRR

Returns internal rate of return for a cash flow stream

NPV

Returns net present value of a cash flow stream

Pmt

Returns a constant payment per period for an annuity

PPmt

Returns principal payment for a given period

PV

Returns present value of a future stream of cash flows

Rate

Returns interest rate per period

Numeric Functions

Version 6.0

Statement

Function

Abs

Returns the absolute value of a number

Exp

Returns the value of e raised to a power

Fix

Returns the integer part of a number

Int

Returns the integer part of a number

IsNumeric

Determines whether a value is a legal number

Log

Returns the natural logarithm of a value

Rnd

Returns a random number

Sgn

Returns a value indicating the sign of a number

Sqr

Returns the square root of a number

Derived
Functions

How to compute other numeric functions

Siebel VB Language Reference

1-9

Quick Reference: Statements and Functions


Objects

Trigonometric Functions

Statement

Function

Atn

Returns the arc tangent of a number

Cos

Returns the cosine of an angle

Sin

Returns the sine of an angle

Tan

Returns the tangent of an angle

Derived Functions

How to compute other trigonometric functions

Objects

1-10

Statement

Function

Clipboard

Accesses the Windows Clipboard

CreateObject

Creates a COM automation object

GetObject

Retrieves a COM object from a file or get the active COM object for a
COM class

Is

Determines whether two object variables refer to the same object

Me

Gets the current object

New

Allocates and initializes a new COM object

Nothing

Sets an object variable to not refer to an object

Object

Declares a COM automation object

Typeof

Checks the class of an object

With

Executes statements on an object or a user-defined type

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


ODBC

ODBC

Version 6.0

Statement

Function

SQLClose

Closes a data source connection

SQLError

Returns a detailed error message (ODBC functions)

SQLExecQuery

Executes an SQL statement

SQLGetSchema

Obtains information about data sources, databases, terminology,


users, owners, tables, and columns

SQLOpen

Establishes a connection to a data source for use by other functions

SQLRequest

Makes a connection to a data source, executes an SQL statement,


returns the results

SQLRetrieve

Returns the results of a select that was executed by SQLExecQuery


into a user-provided array

SQLRetrieveToFile

Returns the results of a select that was executed by SQLExecQuery


into a user-specified file

Siebel VB Language Reference

1-11

Quick Reference: Statements and Functions


Strings

Strings

String Functions

1-12

Statement

Function

GetField

Returns a substring from a delimited source string

Hex

Returns the hexadecimal representation of a number, as a string

InStr

Returns the position of one string within another

LCase

Converts a string to lower case

Left

Returns the left portion of a string

Len

Returns the length of a string or size of a variable

Like Operator

Compares a string against a pattern

LTrim

Removes leading spaces from a string

Mid Function

Returns a portion of a string

Mid Statement

Replaces a portion of a string with another string

Oct

Returns the octal representation of a number, as a string

Right

Returns the right portion of a string

RTrim

Removes trailing spaces from a string

SetField

Replaces a substring within a delimited target string

Space

Returns a string of spaces

Str

Returns the string representation of a number

StrComp

Compares two strings

String

Returns a string consisting of a repeated character

Trim

Removes leading and trailing spaces from a string

UCase

Converts a string to upper case

Siebel VB Language Reference

Version 6.0

Quick Reference: Statements and Functions


Variants

String Conversions

Statement

Function

Asc

Returns an integer corresponding to a character code

CCur

Converts a value to currency

CDbl

Converts a value to double-precision floating point

Chr

Converts a character code to a string

CInt

Converts a value to an integer by rounding

CLng

Converts a value to a long by rounding

CSng

Converts a value to single-precision floating point

CStr

Converts a value to a string

CVar

Converts an number or string to a variant

CVDate

Converts a value to a variant date

Format

Converts a value to a string using a picture format

Val

Converts a string to a number

Variants

Version 6.0

Statement

Function

IsEmpty

Determines whether a variant has been initialized

IsNull

Determines whether a variant contains a NULL value

Null

Returns a null variant

VarType

Returns the type of data stored in a variant

Siebel VB Language Reference

1-13

Quick Reference: Statements and Functions


Variants

1-14

Siebel VB Language Reference

Version 6.0

Language Overview

Setting Up Microsoft Visual Basic to Access the Siebel Applications

. . . . 2-3

Getting Started with Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5


Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Named Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Data Types
Arrays

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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

Comparison Operators (Numeric and String) . . . . . . . . . . . . . . . . . 2-19


Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
Object Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-21
Step 1: Create an Object Variable to Access the Object . . . . . . . . . . . . . . .2-23
Step 2: Use Methods and Properties to Act on Objects . . . . . . . . . . . 2-23

Version 6.0

Siebel VB Language Reference

2-1

Language Overview

Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-24


Trapping Errors Returned by Siebel VB . . . . . . . . . . . . . . . . . . . . . . . . 2-24
Option 1: Trap Errors Within Body of Code . . . . . . . . . . . . . . . . . . 2-25
Option 2: Trap Errors Using an Error Handler . . . . . . . . . . . . . . . . . 2-25
Trapping User-Defined (Non-Siebel VB) Errors . . . . . . . . . . . . . . . . . . 2-26
Trapping Errors Generated by Siebel VB Methods . . . . . . . . . . . . . . . . 2-28

2-2

Siebel VB Language Reference

Version 6.0

Language Overview
Setting Up Microsoft Visual Basic to Access the Siebel Applications

Setting Up Microsoft Visual Basic to Access the Siebel


Applications
If you want to access the Siebel applications through COM using Visual Basic, you
must configure your external programming environment so that it recognizes Siebel
objects. If you use Microsoft Visual Basic 5.0 or later, the required support file must
be in the same directory as the .cfg file you use for your Siebel application, or the
COM Automation Server will not work. Take the following steps to ensure that you
are referencing the correct library.

To set up Microsoft Visual Basic to access the Siebel COM Automation or


Data Server
1 Start Microsoft Visual Basic.
2 Select Standard EXE.
3 Choose Project

 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

Siebel VB Language Reference

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

Siebel VB Language Reference

Version 6.0

Language Overview
Getting Started with Siebel VB

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

code is to follow a set of standardized naming conventions. It doesnt really matter


what conventions you follow as long as everyone in the programming group follows
the same conventions. One very common convention is to prefix each variable with
a letter denoting its type, as shown here.
Data Type

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

Siebel VB Language Reference

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

Siebel VB Language Reference

Version 6.0

Language Overview
Getting Started with Siebel VB

. . .
sSolutionId(cSolution) = oBusComp.GetFieldValue( "Id" )
. . .

use the following:


Set oBusComp = objBusObject.GetBusComp("Opportunity")
With oBusComp
.ClearToQuery
.SetSearchSpec . . .
.ExecuteQuery ForwardBackward
.FirstRecord
.NewRecord NewAfter
.SetFieldValue "QuoteNumber", sQuoteId
.SetFieldValue "Account", sAccount
. . .
sSolutionId(cSolution) =.GetFieldValue( "Id" )
. . .
End With

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

Siebel VB Language Reference

2-7

Language Overview
Conventions

Conventions

This section describes the programming conventions used by Siebel VB.

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))

To pass an argument by reference, use one of the following options:


Call mysub(x)
mysub x
y = myfunction(x)
Call myfunction(x)

2-8

Siebel VB Language Reference

Version 6.0

Language Overview
Conventions

Externally declared subprograms and functions (such as DLL functions) can be


declared to take byVal arguments in their declaration. In that case, those arguments
are always passed byVal.
NOTE: Array variables cannot be passed to externally declared subprograms and

functions.

NOTE: Siebel VB functions support a maximum of 32 arguments. If you need to use


more than 32 arguments, use the Type function to define a custom data type and
pass arguments of this new type.

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

Using this syntax for myfunction, you get:


myfunction id:=1, action:="get", value:=0

Version 6.0

Siebel VB Language Reference

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

With named arguments, order is not important.


The area where named arguments have a significant advantage is in calls to
functions or subprograms that have a mix of required and optional arguments.
Ordinarily, you need to use commas as placeholders in the syntax for the optional
arguments that you do not use. With named arguments, however, you can specify
just the arguments you want to use and their values without regard to their order
in the syntax. For example, if myfunction is defined as:
myfunction(id, action, value, Optional counter)

you can use named arguments as follows:


myfunction id:="1", action:="get", value:="0"

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

Siebel VB Language Reference

Version 6.0

Language Overview
Data Types

Data Types

Basic is a strongly typed language. Variables can be declared implicitly on first


reference by using a type character; if no type character is present, the default type
of Variant is assumed. Alternatively, the type of a variable can be declared explicitly
with the Dim statement. In either case, the variable can contain data only of the
declared type. Variables of a user-defined type must be explicitly declared. Siebel
VB supports standard Basic numeric, string, record, and array data. Siebel VB also
supports Dialog Box Records and Objects (which are defined by the application).

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

Siebel VB Language Reference

2-11

Language Overview
Data Types

Numbers

The five numeric types are:


Table 2-1.

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

4-byte floatingpoint number

-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

8-byte floatingpoint number


8-byte number
with a fixed
decimal point

3.402823466e+38

1.797693134862315d+308

Numeric values are always signed.


Siebel VB has no true Boolean variables. Basic considers 0 to be FALSE and any
other numeric value to be TRUE. Only numeric values can be used as Booleans.
Comparison operator expressions always return 0 for FALSE and -1 for TRUE.
Integer constants can be expressed in decimal, octal, or hexadecimal notation.
Decimal constants are expressed by simply using the decimal representation. To
represent an octal value, precede the constant with &O or &o (for example, &o177).
To represent a hexadecimal value, precede the constant with &H or &h (for example,
&H8001).

2-12

Siebel VB Language Reference

Version 6.0

Language Overview
Data Types

Records

A record, or record variable, is a data structure containing one or more elements,


each of which has a value. Before declaring a record variable, a Type must be
defined. Once the Type is defined, the variable can be declared to be of that type.
The variable name should not have a type character suffix. Record elements are
referenced using dot notation, for example,
record.element

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

Siebel VB Language Reference

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 Characters

Data Type

Suffix

Dynamic String

Integer

Long Integer

&

Single-precision floating-point

Double-precision floating-point

Currency (exact fixed point)

Siebel VB Language Reference

Version 6.0

Language Overview
Data Type Conversions

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

Siebel VB Language Reference

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

Siebel VB Language Reference

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.

Variant Data Type

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.

Variant Value Types

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)

-3.402E38 to -1.401E-45 (negative)


1.401E-45 to 3.402E38 (positive)

5 Double

8 bytes (double)

-1.797E308 to -4.94E-324 (negative)


4.94E-324 to 1.797E308 (positive)

Version 6.0

6 Currency

8 bytes (fixed)

-9.223E14 to 9.223E14

7 Date

8 bytes (double)

Jan 1st, 100 to Dec 31st, 9999

8 String

0 to ~64kbytes

0 to ~64k characters

9 Object

N/A

N/A

Siebel VB Language Reference

2-17

Language Overview
Expressions

A newly-defined Variant defaults to being of Empty type, to signify that it contains


no initialized data. An Empty Variant is converted to zero when used in a numeric
expression, or to an empty string when used in a string expression. To test whether
a variant is uninitialized (empty) use the IsEmpty function (see page 3-175).
Null variants have no associated data and serve only to represent invalid or
ambiguous results. You can test whether a variant contains a null value with the
IsNull function. Null is not the same as Empty, which indicates that a variant has
not yet been initialized.

Expressions

An expression is a collection of two or more terms that perform a mathematical or


logical operation. The terms are usually either variables or functions that are
combined with an operator to evaluate to a string or numeric result. You use
expressions to perform calculations, manipulate variables, or concatenate strings.
Expressions are evaluated according to precedence order. Use parentheses to
override the default precedence order.
The precedence order (from high to low) for the operators is:

 Numeric Operators
 String Operators
 Comparison Operators
 Logical Operators

2-18

Siebel VB Language Reference

Version 6.0

Language Overview
Expressions

Numeric Operators

Operator

Comments

Exponentiation

-,+

Unary minus and plus

*, /

Numeric multiplication or division. For division, the result is a Double.

Integer division. The operands can be Integer or Long.

Mod

Modulus or Remainder. The operands can be Integer or Long.

-, +

Numeric addition and subtraction. The + operator can also be used for
string concatenation.

String Operators

Operator

Comments

&

String concatenation

String concatenation

Comparison Operators (Numeric and String)

Version 6.0

Operator

Comments

>

Greater than

<

Less than

Equal to

<=

Less than or equal to

>=

Greater than or equal to

<>

Not equal to

Siebel VB Language Reference

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

Unary Notoperand can be Integer or Long. The operation is performed


bitwise (one's complement).

AND

Andoperands can be Integer or Long. The operation is performed bitwise.

OR

Inclusive Oroperands can be Integer or Long. The operation is performed


bitwise.

XOR

Exclusive Oroperands can be Integer or Long. The operation is performed


bitwise.

EQV

Equivalenceoperands can be Integer or Long. The operation is performed


bitwise. (A EQV B) is the same as (NOT (A XOR B)).

IMP

Implicationoperands can be Integer or Long. The operation is performed


bitwise. (A IMP B) is the same as ((NOT A) OR B ).

Siebel VB Language Reference

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

Siebel VB Language Reference

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.

Dim oBC as BusComp


set oBC = me.GetPickListBusComp("Sales Stage")

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

Siebel VB Language Reference

Version 6.0

Language Overview
Object Handling

Step 1: Create an Object Variable to Access the Object

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.

Step 2: Use Methods and Properties to Act on Objects

To access an object, property or method, you use this syntax:


appvariable.object.property
appvariable.object.method

For example, me.GetPickListBusComp(Sales Stage) is a value returned by the


GetPickListBusComp method of the BusComp object for the Siebel application,
which is assigned to the Object variable oBC.

Version 6.0

Siebel VB Language Reference

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

Trapping Errors Returned by Siebel VB

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

Siebel VB Language Reference

Version 6.0

Language Overview
Trapping Errors Returned by Siebel VB

Option 1: Trap Errors Within Body of Code

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

Option 2: Trap Errors Using an Error Handler

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

Siebel VB Language Reference

2-25

Language Overview
Trapping User-Defined (Non-Siebel VB) Errors

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

Siebel VB Language Reference

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

Siebel VB Language Reference

2-27

Language Overview
Trapping Errors Generated by Siebel VB Methods

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

About This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15


Abs Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
ActivateField Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveBusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
ActiveViewName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AddChild Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AllowNotification Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
AppActivate Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Applet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_GotFocus Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_Load Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_LostFocus Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Applet_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_Close Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21

Version 6.0

Siebel VB Language Reference

3-1

Siebel VB Language Reference

Application_PreClose Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21


Application_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Application_Start Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Asc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Associate Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
Atn Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Beep Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24
BusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_Associate Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_ChangeRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_CopyRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_DeleteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
BusComp_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_NewRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreAssociate Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreCopyRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreDeleteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
BusComp_PreGetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreInvokeMethod Event

. . . . . . . . . . . . . . . . . . . . . . . . . . 3-27

BusComp_PreNewRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27


BusComp_PreQuery Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreSetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
BusComp_PreWriteRecord Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

3-2

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

BusComp_Query Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28


BusComp_SetFieldValue Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28
BusComp_WriteRecord Event

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28

BusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28


Call Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
CCur Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
CDbl Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
ChDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-35
ChDrive Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
Chr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-38
CInt Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-40

ClearToQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-41


Clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
CLng Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Close Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-45
Const Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-47
Copy Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-48
Cos Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-49
CreateObject Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-50
CSng Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
CStr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-54
CurDir Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-56
CurrencyCode Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-57

Version 6.0

Siebel VB Language Reference

3-3

Siebel VB Language Reference

CVar Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-58


CVDate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-59
Date Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-61
Date Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-62
DateSerial Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-64
DateValue Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-65
Day Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67
DeactivateFields Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-67

Declare Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-68


Deftype Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-71
DeleteRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72
Dim Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-73

Dir Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-79


Do...Loop Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-81
DoEvents Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-82
Drilldown Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-83
Environ Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-84
Eof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
Erase Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-88
Erl Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-90
Err Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-91
Err Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-92
Error Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-94

3-4

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

Error Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-96


ExecuteQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97
ExecuteQuery2 Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97
Exit Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-98
Exp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-99
FileAttr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-101
FileCopy Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-103

FileDateTime Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-105


FileLen Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-107
FindActiveXControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FindApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FindControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FirstRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
FirstSelected Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-108
Fix Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-109
For...Next Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-111
Format Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-114
FreeFile Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-126
Function...End Function Statement . . . . . . . . . . . . . . . . . . . . . . . . . 3-127
FV Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-130
Get Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-132
GetAssocBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-134
GetAttr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-135

Version 6.0

Siebel VB Language Reference

3-5

Siebel VB Language Reference

GetBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137


GetBusObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetChild Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetChildCount Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-137
GetFirstProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetFormattedFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetMVGBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetNamedSearch Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetNextProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-138
GetObject Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-139
GetPicklistBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-141
GetProfileAttr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-141
GetProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetSearchExpr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetSearchSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetService Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetSharedGlobal Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-142
GetType Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
GetUserProperty Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143

GetValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143


GetViewMode Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-143
Global Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-144

3-6

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

GoTo Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-148


GotoApplet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150
GotoControl Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150
GotoView Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-150

Hex Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-151


Hour Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-152
If...Then...Else Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-154
Input Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-156
Input Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-158
InputBox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-160
InputBox Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-162
InsertChildAt Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-162
InStr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-163
Int Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-166
InvokeMethod Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-168
IPmt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-169
IRR Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-171
Is Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-173
IsDate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-174
IsEmpty Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-175
IsMissing Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-177
IsNull Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-179
IsNumeric Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-181

Version 6.0

Siebel VB Language Reference

3-7

Siebel VB Language Reference

Kill Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-183


LastRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-184
LBound Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-185
LCase Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-187
Left Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-188
Len Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-190
Let (Assignment Statement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-191
Like Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-193
Line Input Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-195
Loc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-197
Lock Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-198
Lof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-200
Log Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-201
LoginId Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-202
LoginName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-202
Lset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-203
LTrim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-205
Me . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-206
Mid Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-207
Mid Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-209
Minute Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-211
MkDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-213
Month Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-214

3-8

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

Msgbox Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-216


MsgBox Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-219
Name Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-219
Name Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-220
New Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-222
NewPropertySet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NewRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NextRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
NextSelected Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-223
Nothing Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-224
Now Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-226
NPV Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-227
Null Function
Object Class

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-229
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-231

Oct Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-233


On...GoTo Statement
On Error Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-234
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-235

Open Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-238


Option Base Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-241
Option Compare Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-244
Option Explicit Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-246
ParentBusComp Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-248
Pick Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-248

Version 6.0

Siebel VB Language Reference

3-9

Siebel VB Language Reference

Pmt Function

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-249

PositionId Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251


PositionName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251
PostChanges Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-251
PPmt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-252
PreviousRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-253
Print Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-254
PropertyExists Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-255
Put Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-256
PV Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-258
Randomize Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-260
Rate Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-261
ReDim Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-263
RefineQuery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-265
Rem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-266
RemoveChild() Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268

RemoveProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268


Reset Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-268
Reset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-269
Resume Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-271
Right Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-273
RmDir Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-275
Rnd Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-277

3-10

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

Rset Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-279


RTrim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-281
Second Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-282
Seek Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-284
Seek Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-286
Select Case Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-288
SendKeys Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-291
Service_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-294
Service_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-294
Set Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-295
SetAttr Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-297
SetFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetFormattedFieldValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetNamedSearch Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298

SetProfileAttr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298


SetProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-298
SetSearchExpr Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSearchSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSharedGlobal Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetSortSpec Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetType Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-299
SetUserProperty Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300
SetValue Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300

Version 6.0

Siebel VB Language Reference

3-11

Siebel VB Language Reference

SetViewMode Method

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-300

Sgn Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-301


Shell Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-302
ShowStatus Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-303
Sin Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-304
Space Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-305
Spc Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-306
SQLClose Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-308
SQLError Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-310
SQLExecQuery Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-312
SQLGetSchema Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-314
SQLOpen Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-317
SQLRequest Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-320
SQLRetrieve Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-322
SQLRetrieveToFile Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-325
Sqr Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-327
Static Statement

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-328

Stop Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-330


Str Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-331
StrComp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-332
String Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-334
Sub...End Sub Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-336
SuppressNotification Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-338

3-12

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference

Tab Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-339


Tan Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-341
theApplication Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-342
Time Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-343
Time Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-345
Timer Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-347
TimeSerial Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-349
TimeValue Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-350
Trace Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
TraceOff Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
TraceOn Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-352
Trim Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-353
Type Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-354
Typeof Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-356
UBound Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-357
UCase Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-359
UndoRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-360
Unlock Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-361
Val Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-362
VarType Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-363
WebApplet_InvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-366
WebApplet_PreInvokeMethod Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-366
WebApplet_ShowControl Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-366

Version 6.0

Siebel VB Language Reference

3-13

Siebel VB Language Reference

WebApplet_ShowListColumn Event . . . . . . . . . . . . . . . . . . . . . . . . . 3-366


Weekday Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-367
While...Wend Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-369
Width Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-371
With Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-372
Write Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-374
WriteRecord Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-375
Year Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-376

3-14

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


About This Chapter

About This Chapter

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)

Standard VB commands do not address specific components of the Siebel software


architecture. In this guide, standard VB functions and statements and Siebel VB
methods are always identified as such in the description. For details about Siebel
VB events and methods, see the Siebel Object Interfaces Reference.
This information is also included in the Help system of Siebel Tools. Depending on
the version you are using, the Help system may contain more recent material.

Version 6.0

Siebel VB Language Reference

3-15

Siebel VB Language Reference


Abs Function

Abs Function

This standard VB function returns the absolute value of a number.


Abs(number)

Syntax

Argument

Description

number

Any valid numeric expression

Returns

The absolute value of number.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ActivateField Method

ActivateField Method

ActivateField allows queries to retrieve data for the argument-specified field. It is


used with business component objects. For details, see the Siebel Object Interfaces
Reference.

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

ActiveBusComp returns a Siebel business component associated with the active


applet. This method is used with the application object. For details, see the Siebel
Object Interfaces Reference.

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

Siebel VB Language Reference

3-17

Siebel VB Language Reference


ActiveViewName Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


AppActivate Statement

AppActivate Statement

This standard VB statement activates an application window.


Syntax

AppActivate title
Argument

Description

title

A string expression for the caption-bar name of the application window


to activate

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

This example opens the Windows bitmap file ARCADE.BMP in Paintbrush.


(Paintbrush must already be open, and must not be minimized, before running this
example.)
Sub Button_Click
MsgBox "Opening C:\WINDOWS\ARCADE.BMP in Paintbrush."
AppActivate "Paintbrush - (Untitled)"
SendKeys "%FOC:\WINDOWS\ARCADE.BMP{Enter}",1
MsgBox "File opened."
End Sub

See Also

Version 6.0

SendKeys Statement on page 3-291, and Shell Function on page 3-302

Siebel VB Language Reference

3-19

Siebel VB Language Reference


Applet Method

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

The InvokeMethod Siebel VB event handler is triggered by a call to


Applet.InvokeMethod or a specialized method, or by a user-defined menu. For
details, see the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Applet_PreInvokeMethod Event

Applet_PreInvokeMethod Event

The PreInvokeMethod Siebel VB event handler is called before a specialized method


is invoked by the system, by a user-defined applet menu, or by calling
InvokeMethod on an applet. For details, see the Siebel Object Interfaces Reference.

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

The InvokeMethod Siebel VB event handler is called after a specialized method is


invoked. For details, see the Siebel Object Interfaces Reference.

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

The PreInvokeMethod Siebel VB event handler is called before a specialized method


is invoked by a user-defined applet menu or by calling InvokeMethod on the
application. For details, see the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

3-21

Siebel VB Language Reference


Asc Function

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

A string expression of one or more characters

Returns

An integer corresponding to the ANSI code of the first character in the argument.

Usage

To change an ANSI code to string characters, use Chr.

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

Chr Function on page 3-38

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Atn Function

Atn Function

This standard VB function returns the angle (in radians) for the arctangent of the
specified number.
Syntax

Atn(number)
Argument

Description

number

Any valid numeric expression

Returns

The arctangent of number.

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

Siebel VB Language Reference

3-23

Siebel VB Language Reference


Beep Statement

Beep Statement

This standard VB statement sounds a tone through the computers speaker.


Beep

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

This example sounds a beep if the users input is not valid.


Sub Button_Click
Dim x As Integer
x = InputBox("Enter a number:")
if (not isnumeric(x)) or (len(x) = 0) then
MsgBox("You didnt enter a number.")
Beep
end if
End Sub

3-24

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


BusComp Method

BusComp Method

The BusComp Siebel VB method returns a Siebel business component that is


associated with an object, service, or control. It is used with applet objects, service
objects, web applet objects, and control objects. For details, see the Siebel Object
Interfaces Reference.

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

Siebel VB Language Reference

3-25

Siebel VB Language Reference


BusComp_InvokeMethod Event

BusComp_InvokeMethod Event

The InvokeMethod Siebel VB event handler is called when a specialized method is


called on a Siebel business component. For details, see the Siebel Object Interfaces
Reference.

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

The PreAssociate Siebel VB event handler is called before a record is added to a


Siebel business component to create an association. The semantics are the same as
BusComp_PreNewRecord. For details, see the Siebel Object Interfaces Reference.

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

The PreDeleteRecord Siebel VB event handler is called before a row is deleted in a


Siebel business component. The event may be used to prevent the deletion or to
perform any actions in which you need access to the record that is to be deleted.
For details, see the Siebel Object Interfaces Reference.

3-26

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


BusComp_PreGetFieldValue Event

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

The PreInvokeMethod Siebel VB event handler is called before a specialized method


is invoked on a Siebel business component. For details, see the Siebel Object
Interfaces Reference.

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

The PreSetFieldValue Siebel VB event handler is called before 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.

Version 6.0

Siebel VB Language Reference

3-27

Siebel VB Language Reference


BusComp_PreWriteRecord Event

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Call Statement

Call Statement

This standard VB function transfers control to a subprogram or function.


Syntax A

Call subprogram_name [(argument_list)]

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

The arguments, if any, to be passed to the subroutine or function

Returns

If a function, its output; if a subprogram, not applicable.

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)

The following calls to this procedure are all equivalent:


call mysub(1, 2, , 4)
mysub aa := 1, bb := 2, dd := 4
call mysub(aa := 1, dd:= 4, bb :=
mysub 1, 2, dd:= 4

2)

The syntax for named arguments is as follows:


argname := argvalue

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

Siebel VB Language Reference

3-29

Siebel VB Language Reference


Call Statement

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:

 All functions defined with the Function statement.


 All subprograms defined with the Sub statement.
 All procedures declared with Declare statement.
 Many built-in functions and statements (such as InputBox).
 Some externally registered DLL functions and methods.
Arguments are passed by reference to procedures written in Basic. If you pass a
variable to a procedure that modifies its corresponding formal parameter, and you
do not want to have your variable modified (that is, if you need to retain the
before value), enclose the variable in parentheses in the Call statement. This will
tell Siebel VB to pass a copy of the variable. (This is called passing by value.) Note,
however, that generally passing by value is less efficient, and should not be done
unless necessary.
When a variable is passed to a procedure that expects its argument by reference, the
variable must match the exact type of the formal parameter of the function. (This
restriction does not apply to expressions or variants.)
When calling an external DLL procedure, arguments can be passed by value rather
than by reference. This is specified in the Declare statement, the Call itself, or both,
using the ByVal keyword. If ByVal is specified in the declaration, then the ByVal
keyword is optional in the call. If present, it must precede the value. If ByVal was
not specified in the declaration, it is illegal in the call unless the data type was
unspecified in the declaration.

3-30

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Call Statement

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

Declare Statement on page 3-68

Siebel VB Language Reference

3-31

Siebel VB Language Reference


CCur Function

CCur Function

This standard VB function converts an expression to the data type currency.


CCur(expression)

Syntax

Argument

Description

expression

Any expression that evaluates to a number

Returns

The value of expression as a number of type currency.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CCur Function

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

Siebel VB Language Reference

3-33

Siebel VB Language Reference


CDbl Function

CDbl Function

This standard VB function converts an expression to the data type double.


CDbl(expression)

Syntax

Argument

Description

expression

Any expression that evaluates to a number

Returns

The value of expression as a double-precision number.

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

This example calculates the square root of 2 as a double-precision floating point


value and displays it in scientific notation.
Sub Button_Click
Dim value
Dim msgtext
value = CDbl(Sqr(2))
msgtext = "The square root of 2 is: " & Value
MsgBox msgtext
End Sub

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ChDir Statement

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

The name of the directory to become the default, or a string expression


representing the directory name

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

Siebel VB Language Reference

3-35

Siebel VB Language Reference


ChDir Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ChDrive Statement

ChDrive Statement

This standard VB statement changes the default drive.


Syntax

ChDrive drive
Argument

Description

drive

A string expression designating the new default 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

This example changes the default drive to A.


Sub Button_Click
Dim newdrive as String
newdrive = "A"
If Left(CurDir,2) <> newdrive then
ChDrive newdrive
End If
MsgBox "The default drive is now " & newdrive
End Sub

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

Siebel VB Language Reference

3-37

Siebel VB Language Reference


Chr Function

Chr Function

This standard VB function returns the one-character string corresponding to an


ANSI code.
Chr[$](charCode)

Syntax

Argument

Description

charCode

An integer between 0 and 255 representing the ANSI code for a character

Returns

The character represented by charcode.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Chr Function

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

Siebel VB Language Reference

3-39

Siebel VB Language Reference


CInt Function

CInt Function

This standard VB function converts an expression to the data type integer by


rounding.
CInt(expression)

Syntax

Argument

Description

expression

Any expression that evaluates to a number

Returns

The value of expression as an integer.

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

This example calculates the average of ten 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 golf score #" & x & ":")
sum = sum + score
Next x
msgtext = "Your average is: " & _
Format(CInt(sum/ (x - 1)), "General Number")
MsgBox msgtext
End Sub

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ClearToQuery Method

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

Siebel VB Language Reference

3-41

Siebel VB Language Reference


Clipboard

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

A string or string expression containing the text to send to the Clipboard

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

Clears the contents of the Clipboard

GetText

Returns a text string from the Clipboard

SetText

Puts a text string to the Clipboard

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Clipboard

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

Siebel VB Language Reference

3-43

Siebel VB Language Reference


CLng Function

CLng Function

This standard VB function converts an expression to the data type long by rounding.
CLng(expression)

Syntax

Argument

Description

expression

Any expression that can evaluate to a number

Returns

The value of expression as a number of type long.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Close Statement

Close Statement

This standard VB statement closes a file, concluding input/output to that file.


Syntax

Close [[#]filenumber [, [#]filenumber ... ]]


Argument

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

Siebel VB Language Reference

3-45

Siebel VB Language Reference


Close Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Const Statement

Const Statement

This standard VB statement declares symbolic constants for use in a Basic program.
Syntax

[Global] Const constantName [As type ] = expression [, constantName [As type ]


= expression ] ...
Argument

Description

constantName

The variable name to contain a constant value

type

The data type of the constant (Number or String)

expression

Any expression that evaluates to a constant number

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 CLng Function on page 3-44 for an 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

Siebel VB Language Reference

3-47

Siebel VB Language Reference


Copy Method

Copy Method

Copy returns a copy of a property set. For details, see the Siebel Object Interfaces
Reference.

3-48

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Cos Function

Cos Function

This standard VB function returns the cosine of an angle.


Syntax

Cos(number)
Argument

Description

number

An angle in radians

Returns

The cosine of number.

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

Siebel VB Language Reference

3-49

Siebel VB Language Reference


CreateObject Function

CreateObject Function

Creates a new COM automation object.


CreateObject(application.objectname)

Syntax

Argument

Description

application

The name of the application

objectname

The name of the object to be used

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CreateObject Function

' Make Excel visible through the Application object.


oWorkSheet.Application.Visible = 1
' Place some text in the first cell of the sheet
oWorkSheet.ActiveSheet.Cells(1,1).Value = "Column A, Row 1"
' Save the sheet
sfileName = "C:\demo.xls"
oWorkSheet.SaveAs (fileName)
' Close Excel with the Quit method on the Application object
oWorkSheet.Application.Quit
' Clear the object from memory
Set oWorkSheet = Nothing
End Sub

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

GetObject Function on page 3-139, Is Operator on page 3-173, Me on page 3-206,


New Operator on page 3-222, Nothing Function on page 3-224, Object Class on
page 3-231, and Typeof Function on page 3-356

Siebel VB Language Reference

3-51

Siebel VB Language Reference


CSng Function

CSng Function

This standard VB function converts an expression to the data type single.


CSng(expression)

Syntax

Argument

Description

expression

Any expression that can evaluate to a number

Returns

The value of expression as a single-precision floating-point number.

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

This example calculates the factorial of a number. 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 number as Integer
Dim factorial as Double
Dim msgtext As String
number = InputBox("Enter an integer between 1 and 170:")
If number <= 0 then
Exit Sub
End If

3-52

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CSng Function

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

Siebel VB Language Reference

3-53

Siebel VB Language Reference


CStr Function

CStr Function

This standard VB function converts an expression to the data type string.


CStr(expression)

Syntax

Returns

Example

Argument

Description

expression

Any expression that can evaluate to a number

A string containing the value of expression.


If expression is:

CStr returns:

Date

A string containing a date

Empty

A zero-length string ("")

Error

A string containing Error, followed by the error number

Null

A run-time error

Other Numeric

A string containing the number

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CStr Function

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

Siebel VB Language Reference

3-55

Siebel VB Language Reference


CurDir Function

CurDir Function

This standard VB function returns the default directory (and drive) for the specified
drive.
CurDir[$][(drive)]

Syntax

Argument

Description

drive

The letter of the drive to search

Returns

The default drive and directory.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CurrencyCode Method

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

Siebel VB Language Reference

3-57

Siebel VB Language Reference


CVar Function

CVar Function

This standard VB function converts an expression to the data type variant.


CVar(expression)

Syntax

Argument

Description

expression

Any expression that can evaluate to a number

Returns

The expression as an expression of type variant.

Usage

CVar accepts any type of expression.


CVar generates the same result as you would get by assigning the expression to a
variant variable.

Example

This example converts a string variable to a variant variable.


Sub Button_Click
Dim answer as Single
answer = 100.5
MsgBox "'Answer' is declared as Single with the value: " _
& answer
answer = CVar(answer)
MsgBox "'Answer' is now a variant with a type of: " &
VarType(answer)
End Sub

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


CVDate Function

CVDate Function

This standard VB function converts an expression to the data type variant of type
date.
Syntax

CVDate(expression)
Argument

Description

expression

Any expression that can evaluate to a number

Returns

The value of expression expressed as a variant of vartype 7 (date).

Usage

CVDate accepts both string and numeric values.


The CVDate function returns a variant of vartype 7 (date) that represents a date
from January 1, 100 through December 31, 9999. A value of 2 represents January 1,
1900. Times are represented as fractional days.
CVDate converts the time portion of a date expression if one is included as part of
the expression, or if the time expression is the only argument. See the Format
Function on page 3-114 for ways to display the desired result of a date conversion.

Version 6.0

Siebel VB Language Reference

3-59

Siebel VB Language Reference


CVDate Function

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

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, DateValue Function on page 3-65, Format Function on
page 3-114, and Val Function on page 3-362

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Date Function

Date Function

This standard VB function returns a string representing the current date as


determined by the system clock.
Syntax

Date[$]
Argument

Description

Not applicable

Returns

The current date, as a value of type string.

Usage

The Date function returns a ten-character string.


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 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

Siebel VB Language Reference

3-61

Siebel VB Language Reference


Date Statement

Date Statement

This standard VB function sets the system date.


Date[$] = expression

Syntax

Argument

Description

expression

A string in one of the following forms:

 mm-dd-yy
 mm-dd-yyyy
 mm/dd/yy
 mm/dd/yyyy

In the above string forms, the placeholders are interpreted as follows:


Placeholder

Meaning

mm

A month expressed as a two-digit number (0112)

dd

A day expressed as a two-digit number (0131)

yy

A year expressed as a two-digit number (0099)

yyyy

A year expressed as a four-digit number (19802099)

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Date Statement

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

Siebel VB Language Reference

3-63

Siebel VB Language Reference


DateSerial Function

DateSerial Function

This standard VB function returns a date value for year, month, and day specified.
DateSerial(year, month, day)

Syntax

Argument

Description

year

An integer representing a year between 100 and 2099 or a numeric


expression

month

An integer representing a month between 1 and 12 or a numeric expression

day

An integer representing a day between 1 and 31, or a numeric expression

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


DateValue Function

DateValue Function

This standard VB function returns a date value for the string specified.
Syntax

DateValue(date)
Argument

Description

date

A string representing a valid 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

Siebel VB Language Reference

3-65

Siebel VB Language Reference


DateValue Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Day Function

Day Function

This standard VB function returns the day of the month of a date-time value.
Syntax

Day(date)
Argument

Description

date

Any expression that can evaluate to a 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

Siebel VB Language Reference

3-67

Siebel VB Language Reference


Declare Statement

Declare Statement

This standard VB statement declares a procedure in a module or dynamic link


library (DLL).
Syntax A

Declare Sub name [(parameter [As type])]

Syntax B

Declare Function name [(parameter [As type])] [As funcType]

Returns

Argument

Description

name

The name of the subprogram or function procedure to declare

parameter

The arguments to pass to the procedure, separated by commas

type

The data type for the arguments

funcType

The data type of the return value of the function

Syntax A: Not applicable


Syntax B: A value of the type funcType, which can be used in an expression.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Declare Statement

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

before Sub A will allow the code to compile and run.


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; array dimensions are not
specified in the Declare statement.
External DLL procedures are called with the Pascal calling convention (the actual
arguments are pushed on the stack from left to right). By default, the actual
arguments are passed by Far reference. For external DLL procedures, there are two
additional keywords, ByVal and Any, that can be used in the parameter list.
When ByVal is used, it must be specified before the parameter it modifies. When
applied to numeric data types, ByVal indicates that the parameter is passed by
value, not by reference. When applied to string parameters, ByVal indicates that the
string is passed by Far pointer to the string data. By default, strings are passed by
Far pointer to a string descriptor.

Version 6.0

Siebel VB Language Reference

3-69

Siebel VB Language Reference


Declare Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Deftype Statement

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

The first letter of a variable name to use

Returns

Not applicable

Usage

VarTypeLetters can be a single letter, a comma-separated list of letters, or a range of


letters. For example, a-d indicates the letters a, b, c, and d.
The case of the letters is not important, even in a letter range. The letter range a-z
is treated as a special case: it denotes all alpha characters, including the
international characters.
The Deftype statement affects only the module in which it is specified. It must
precede any variable definition within the module.
Variables defined using a Global or Dim statement can override the Deftype
statement by using an As clause or a type character.

Version 6.0

Siebel VB Language Reference

3-71

Siebel VB Language Reference


DeleteRecord Method

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

DeleteRecord removes the current record from a Siebel business component. It is


used with business component objects. For details, see the Siebel Object Interfaces
Reference.

3-72

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Dim Statement

Dim Statement

This standard VB statement declares variables for use in a Basic program.


Syntax

Dim [Shared] variableName [As[ New] type] [, variableName [As[ New] type]] ...
Placeholder

Description

variableName

The name of the variable to declare

type

The data type of the variable

Returns

Not applicable

Usage

Dim is a declaration statement. It is shorthand for Declare in Memory; however, you


must use the short form.
VariableName must begin with a letter and contain only letters, numbers and
underscores. A name can also be delimited by brackets, and any character can be
used inside the brackets, except for other brackets.
Dim my_1st_variable As String
Dim [one long and strange! variable name] As String

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

Siebel VB Language Reference

3-73

Siebel VB Language Reference


Dim Statement

 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Dim Statement

Caution: You may declare several variables on one line; however,


unless you include the type for each variable, the type applies only
to the last variable declared. For example,
Dim Acct, CustName, Addr As String

causes only Addr to be declared as type string; the other variables


are implicitly declared as type variant. On the other hand,
Dim Acct As String, CustName As String, Addr As
String

declares all the variables as type string.

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

The index number of the last element of the array

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

Siebel VB Language Reference

3-75

Siebel VB Language Reference


Dim Statement

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

An object can be declared as New for some classes. For example:


Dim variableName As New className
variableName.methodName

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Dim Statement

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

Variant variables are initialized to vartype Empty.

Version 6.0

Siebel VB Language Reference

3-77

Siebel VB Language Reference


Dim Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Dir Function

Dir Function

The standard VB function Dir returns a filename that matches the specified pattern,
having the specified attributes.
Syntax

Returns

Dir[$] [(pathname[, attributes])]


Argument

Description

pathname

A string or string expression evaluating to a path or filename

attributes

An integer expression specifying the file attributes to select

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)

Normal files (no attributes set)

Normal and hidden files

Normal and system files

Volume label (only)

16

Normal files and directories

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

Siebel VB Language Reference

3-79

Siebel VB Language Reference


Dir Function

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

This example lists the contents of the diskette in drive A.


Sub Button_Click
Dim msgReturn
Dim directory, count
Dim x, msgtext
Dim A()
msgReturn = MsgBox("Insert a disk in drive A.")
count = 1
ReDim A(100)
directory = Dir ("A:\*.*")
Do While directory <> ""
A(count) = directory
Count = count + 1
directory = Dir
loop
msgtext = "Contents of drive A:\ is:" & Chr(10) & Chr(10)
For x = 1 to count
msgtext = msgtext & A(x) & Chr(10)
Next x
MsgBox msgtext
End Sub

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Do...Loop Statement

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

Any expression that evaluates to TRUE (non-zero) or FALSE (0)

statement_block

Program lines to repeat while (or until) condition is TRUE (non-zero)

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

Siebel VB Language Reference

3-81

Siebel VB Language Reference


DoEvents Statement

DoEvents Statement

This standard VB statement transfers execution to Windows for processing


operating system events.
DoEvents

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Drilldown Method

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

Siebel VB Language Reference

3-83

Siebel VB Language Reference


Environ Function

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

The name of a keyword in the operating system

numeric_expression

An integer for the position of the string in the environment table


(1st, 2nd, 3rd, and so on)

Returns

The string value assigned to an environment variable.

Usage

If you use the environment-string parameter, enter it in uppercase, or Environ


returns a null string (""). The return value for Syntax A is the string associated with
the keyword requested.
If you use the numeric_expression parameter, the numeric expression is
automatically rounded to a whole number, if necessary. The return value for Syntax
B is a string in the form KEYWORD=value.
Environ returns a null string if the specified argument cannot be found.
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-84

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Environ Function

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

Siebel VB Language Reference

3-85

Siebel VB Language Reference


Eof Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Eof Function

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

Siebel VB Language Reference

3-87

Siebel VB Language Reference


Erase Statement

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

The name of the array variable to re-initialize

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

Each element is set to zero.

Variable-length string

Each element is set to a zero-length string ("").

Fixed-length string

Each elements string is filled with zeros.

Variant

Each element is set to Empty.

User-defined type

Members of each element are cleared as if the members were


array elements; that is, numeric members have their values set
to zero, the strings to "", and so on.

Object

Each element is set to the special value Nothing.

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Erase Statement

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

Siebel VB Language Reference

3-89

Siebel VB Language Reference


Erl Function

Erl Function

This standard VB function returns the line number where an error was trapped.
Erl

Syntax

Argument

Description

Not applicable

Returns

The line number on which an error occurred.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Err Function

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

Siebel VB Language Reference

3-91

Siebel VB Language Reference


Err Statement

Err Statement

This standard VB statement sets a run-time error code.


Err = errornumber

Syntax

Argument

Description

errornumber

An integer between 1 and 32,767 representing an error code, or a 0 if no


error occurs

Returns

Not applicable

Usage

The Err statement is used to send error information between procedures.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Err Statement

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

Siebel VB Language Reference

3-93

Siebel VB Language Reference


Error Function

Error Function

This standard VB function returns the error message that corresponds to the
specified error code.
Error[$] [(errornumber)]

Syntax

Returns

Argument

Description

errornumber

An integer between 1 and 32,767 representing an error code

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Error Function

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

Siebel VB Language Reference

3-95

Siebel VB Language Reference


Error Statement

Error Statement

This standard VB statement simulates the occurrence of a Siebel VB or user-defined


error.
Syntax

Usage

Error errornumber
Argument

Description

errornumber

An integer between 1 and 32,767 representing an error code

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.

If an Error statement is executed, and there is no error-handling routine enabled,


Siebel VB produces an error message and halts program execution. If an Error
statement specifies an error code not used by Siebel VB, the message User-defined
error is displayed.

3-96

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ExecuteQuery Method

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

ExecuteQuery returns a set of business component records using the criteria


established with methods such as SetSearchSpec. It is used with business
component objects. For details, see the Siebel Object Interfaces Reference.

ExecuteQuery2 Method

ExecuteQuery2 returns a set of business component records using the criteria


established with methods such as SetSearchSpec. It is used with business
component objects. For details, see the Siebel Object Interfaces Reference

Version 6.0

Siebel VB Language Reference

3-97

Siebel VB Language Reference


Exit Statement

Exit Statement

This standard VB statement terminates loop statements or transfers control to a


calling procedure.
Syntax

Exit {Do | For | Function | Sub}

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

Do...Loop Statement on page 3-81, FindActiveXControl Method on page 3-108,


Function...End Function Statement on page 3-127, and Sub...End Sub Statement on
page 3-336

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Exp Function

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

The exponent value for e

Returns

The value of e raised to the power number.

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

Siebel VB Language Reference

3-99

Siebel VB Language Reference


Exp Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


FileAttr Function

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

An integer representing the type of information to return

Returns
If returntype is:
1

Returns:
The file mode of the open file, where

 1 indicates Input mode


 2 indicates Output mode
 8 indicates Append mode
2

Usage

Version 6.0

The operating system handle of the open file

The argument filenumber is the number used in the Open statement to open the file.

Siebel VB Language Reference

3-101

Siebel VB Language Reference


FileAttr Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


FileCopy Statement

FileCopy Statement

This standard VB function copies a file.


Syntax

FileCopy [path1]source, [path2]target


Argument

Description

path1

The path of the file to copy (optional unless source$ is not in the current
directory)

source

The name, and if necessary, the path, of the file to copy

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

The name to which the file should be copied

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

Siebel VB Language Reference

3-103

Siebel VB Language Reference


FileCopy Statement

See Also

3-104

FileAttr Function on page 3-101, FileDateTime Function on page 3-105, GetAttr


Function on page 3-135, Kill Statement on page 3-183, and Name Statement on
page 3-220

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


FileDateTime Function

FileDateTime Function

This standard VB function returns the last modification date and time for the
specified file.
Syntax

FileDateTime(pathname)
Argument

Description

pathname

A string or string expression evaluating to the name of the file to query

Returns

The date and time the file was last modified.

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

Siebel VB Language Reference

3-105

Siebel VB Language Reference


FileDateTime Function

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

FileLen Function on page 3-107, and GetAttr Function on page 3-135

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


FileLen Function

FileLen Function

This standard VB function returns the length of the specified file.


Syntax

FileLen(pathname)
Argument

Description

pathname

A string or string expression evaluating to the name of the file to query

Returns

The length of the file specified in pathname.

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

This example returns the length of a file.


Sub Button_Click
Dim length as Long
Dim userfile as String
Dim msgtext
On Error Resume Next
msgtext = "Enter a filename:"
userfile = InputBox(msgtext)
length = FileLen(userfile)
If Err <> 0 then
msgtext = "Error occurred. Rerun program."
Else
msgtext = "The length of " & userfile & " is: " & length
End If
MsgBox msgtext
End Sub

See Also

Version 6.0

FileDateTime Function on page 3-105, GetAttr Function on page 3-135, and Lof
Function on page 3-200

Siebel VB Language Reference

3-107

Siebel VB Language Reference


FindActiveXControl Method

FindActiveXControl Method

FindActiveXControl returns the ActiveX Control whose name is specified in the


argument. It is used with applet objects. For details, see the Siebel Object Interfaces
Reference.

FindApplet Method

FindApplet returns the applet that is identified by the appletName argument. It is


used with the application object. For details, see the Siebel Object Interfaces
Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Fix Function

Fix Function

This standard VB function returns the integer part of a number.


Syntax

Fix(number)
Argument

Description

number

Any valid numeric expression

Returns

The integer part of number.

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

Siebel VB Language Reference

3-109

Siebel VB Language Reference


Fix Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


For...Next Statement

For...Next Statement

This standard VB control structure repeats a series of program lines a fixed number
of times.
Syntax

For counter = start To end [Step increment]


statement_block
[Exit For]
statement_block
Next [counter]
Placeholder

Description

counter

A numeric variable for the loop counter

start

The initial value of the counter

end

The ending value of the counter

increment

The amount by which the counter is changed each time the loop is
run; the default is 1

statement_block

the Basic functions, statements, or methods to be executed

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

Siebel VB Language Reference

3-111

Siebel VB Language Reference


For...Next Statement

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

The loop repeats until counter is less than end.

Zero

The loop repeats indefinitely.

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

For an example, see CSng Function on page 3-52.

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


For...Next Statement

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

Siebel VB Language Reference

3-113

Siebel VB Language Reference


Format Function

Format Function

This standard VB function returns a formatted string of an expression based on a


given format.
Syntax

Format[$](expression[, format])
Argument

Description

expression

The value to be formatted; it can be a number, string, or variant

format

A string expression representing the format to use

Select one of the topics below for a detailed description of format strings.
Returns

The expression in the specified format.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

Formatting Numbers
The predefined numeric formats with their meanings are as follows:

Version 6.0

Format

Description

General
Number

Displays the number without thousand separator.

Fixed

Displays the number with at least one digit to the left and at least two
digits to the right of the decimal separator.

Standard

Displays the number with thousand separator and two digits to the right
of decimal separator.

Scientific

Displays the number using standard scientific notation.

Currency

Displays the number using a currency symbol as defined in the


International section of the Control Panel. Use thousand separator and
display two digits to the right of decimal separator. Enclose negative value
in parentheses.

Percent

Multiplies the number by 100 and displays it with a percent sign


appended to the right; displays two digits to the right of decimal separator.

True/False

Displays FALSE for 0, TRUE for any other number.

Yes/No

Displays No for 0, Yes for any other number.

On/Off

Displays Off for 0, On for any other number.

Siebel VB Language Reference

3-115

Siebel VB Language Reference


Format Function

To create a user-defined numeric format, follow these guidelines:


For a simple numeric format, use one or more digit characters and (optionally) a
decimal separator. The two format digit characters provided are zero, 0, and
number sign, #. A zero forces a corresponding digit to appear in the output; while
a number sign causes a digit to appear in the output if it is significant (in the middle
of the number or non-zero).
Number

Format

Result

1234.56

1235

1234.56

#.##

1234.56

1234.56

#.#

1234.6

1234.56

######.##

1234.56

1234.56

00000.000

01234.560

0.12345

#.##

.12

0.12345

0.##

0.12

A comma placed between digit characters in a format causes a comma to be placed


between every three digits to the left of the decimal separator.
Number

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

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

Siebel VB Language Reference

3-117

Siebel VB Language Reference


Format Function

Numbers can be formatted in scientific notation by including one of the following


exponent strings in the format specification:
E- E +

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

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

"The value is: "

0.00

Siebel VB Language Reference

3-119

Siebel VB Language Reference


Format Function

Formatting Dates and Times


As with numeric formats, there are several predefined formats for formatting dates
and times:
Format

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

Displays a Long Date; Long Date is defined in the International section


of the Control Panel

Medium Date

Displays the date using the month abbreviation, without the day of the
week (for example, 08-Nov-93)

Short Date

Displays a Short Date; Short Date is defined in the International section


of the Control Panel

Long Time

Displays a Long Time; Long Time is defined in the International section


of the Control Panel and includes hours, minutes, and seconds

Medium Time

Does not display seconds; displays hours in 12-hour format and uses the
AM/PM designator

Short Time

Does not display seconds; uses 24-hour format and no AM/PM


designator

In a user-defined format for a date, the format specification contains a series of


tokens. Each token is replaced in the output string by its appropriate value.

3-120

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

A complete date can be output by using a combination of the following tokens:


Token

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

The day of the month as a one or two digit number (131)

dd

The day of the month as a two digit number (0131)

ddd

The day of the week as a three letter abbreviation (SunSat)

dddd

The day of the week without abbreviation (SundaySaturday)

The day of the week as a number (Sunday as 1, Saturday as 7)

ww

The week of the year as a number (153)

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

The month of the year as a three letter abbreviation (JanDec)

mmmm

The month of the year without abbreviation (JanuaryDecember)

Siebel VB Language Reference

3-121

Siebel VB Language Reference


Format Function

Token

Output

The quarter of the year as a number (14)

The day of the year as a number (1366)

yy

The year as a two-digit number (0099)

yyyy

The year as a three- or four-digit number (1009999)

The hour as a one- or two-digit number (023)

hh

The hour as a two digit number (0023)

The minute as a one- or two-digit number (059)

nn

The minute as a two-digit number (0059)

The second as a one- or two-digit number (059)

ss

The second as a two-digit number (0059)

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

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

Output a character or a space; if there is a character in the string being


formatted in the position where the @ appears in the format string, display
it; otherwise, display a space in that position

&

Output a character or nothing; if there is a character in the string being


formatted in the position where the & appears, display it; otherwise, display
nothing

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

Siebel VB Language Reference

3-123

Siebel VB Language Reference


Format Function

Examples

This example demonstrates some of the string-formatting tokens. The result


appears in the figure following the example
Sub Button1_Click
Dim msgtext As String
msgtext = Format("Section #AB-234", "<\[&&&&&&&&&&&&&&&\]") _
& Chr$(13) & Chr$(13) & Format("incoming", ">@@@@@@@@\!\!") _
& Chr$(13) & Chr$(13) _
& Format("Profits are expected to rise.", _
"!&&&&&&&&&&&&&&&&&")
MsgBox msgtext, , "String Formats"
End Sub

Figure 3-1.

Formatting Strings

This example calculates the square root of 2 as a double-precision floating point


value and displays it in scientific notation.
Sub Button1_Click
Dim value As Double
Dim msgtext As String
value = CDbl(Sqr(2))
msgtext = "The square root of 2 is " & Format(value,
"Scientific")
MsgBox msgtext, mbOKOnly, "Scientific Notation"
End Sub

Figure 3-2.

3-124

Formatting Numbers

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Format Function

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.

Formatting Dates and Times

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

Siebel VB Language Reference

3-125

Siebel VB Language Reference


FreeFile Function

FreeFile Function

This standard VB function returns the lowest unused file number.


Syntax

FreeFile
Argument

Description

Not applicable

Returns

The lowest file number not in use.

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

Open Statement on page 3-238

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Function...End Function Statement

Function...End Function Statement

This standard VB construct defines a function procedure.


Syntax

[ Static ] [ Private ] Function name([[Optional ]parameter


[As type ]][, ... ]) [As funcType]
name = expression
End Function
Placeholder

Description

name

The name of the function

parameter

The argument to pass to the function when it is called

type

The data type for the argument

funcType

The data type for the value returned by the function

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

Siebel VB Language Reference

3-127

Siebel VB Language Reference


Function...End Function Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Function...End Function Statement

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

Siebel VB Language Reference

3-129

Siebel VB Language Reference


FV Function

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

FV(rate, nper, pmt, pv, due)


Argument

Description

rate

The interest rate per period

nper

The total number of payment periods

pmt

The constant periodic payment per period

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

A number representing the future value of an investment such as an annuity or


loan.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


FV Function

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

Siebel VB Language Reference

3-131

Siebel VB Language Reference


Get Statement

Get Statement

This standard VB function reads data from a file opened in Random or Binary mode
and puts it in a variable.
Syntax

Get [#]filenumber, [recnumber], varName


Argument

Description

filenumber

The file number used in the Open statement to open the file

recnumber

An expression of type long containing either the number of the record at


which to start reading in Random mode, or the offset of the byte at which
to start reading in Binary mode

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Get Statement

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:

 Get reads variables from the disk without record padding.


 Variable-length Strings that are not part of user-defined types are not preceded
by the two-byte string length. Instead, the number of bytes read is equal to the
length of varName.
Example

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

Siebel VB Language Reference

3-133

Siebel VB Language Reference


GetAssocBusComp Method

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

GetAssocBusComp returns the association business component. The association


business component can be used to operate on the association using the normal
business component mechanisms. This method is used with business component
objects. For details, see the Siebel Object Interfaces Reference.

3-134

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GetAttr Function

GetAttr Function

This standard VB function returns the attributes of a file, directory, or volume label.
Syntax

Returns

Usage

GetAttr(pathname)
Argument

Description

pathname

A string or string expression evaluating to the name of the file, directory, or


volume label to query

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

Archivefile has changed since last backup

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

Siebel VB Language Reference

3-135

Siebel VB Language Reference


GetAttr Function

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

FileAttr Function on page 3-101, and SetAttr Statement on page 3-297

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GetBusComp Method

GetBusComp Method

The GetBusComp method returns the specified Siebel business component. it is


used with Siebel business objects. For details, see the Siebel Object Interfaces
Reference.

GetBusObject Method

GetBusObject method instantiates and returns a new instance of the argument


specified business object. It is used with the application object. For details, see the
Siebel Object Interfaces Reference.

GetChild Method

GetChild returns a specified child property set of a property set. For details, see the
Siebel Object Interfaces Reference.

GetChildCount Method

GetChildCount returns the number of child property sets attached to a parent


property set. For details, see the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

3-137

Siebel VB Language Reference


GetFirstProperty Method

GetFirstProperty Method

GetFirstProperty retrieves the name of the first property of a business service or


property set. For details, see the Siebel Object Interfaces Reference.

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

GetMVGBusComp returns the MVG business component associated with a Siebel


business component field. This business component can be used to operate on the
multi-value group using the normal business component mechanisms. This method
is used with business component objects. For details, see the Siebel Object Interfaces
Reference.

GetNamedSearch Method

GetNamedSearch returns the named search specification specified by searchName.


It is used with business component objects. For details, see the Siebel Object
Interfaces Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GetObject Function

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

The full path and filename for the object to retrieve

class

A string containing the class of the object

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

Siebel VB Language Reference

3-139

Siebel VB Language Reference


GetObject Function

Syntax B of GetObject accesses a COM object of a particular class that is stored in


a file. Class uses the syntax appName.objectType, where appName is the name of
the application that provides the object, and objectType is the type or class of the
object. For example:
Dim oClassObject As Object
Set oClassObject = GetObject("C:\My _
Documents\payables.xls", "Excel.Sheet")

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GetPicklistBusComp Method

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

CreateObject Function on page 3-50, Is Operator on page 3-173, Me on page 3-206,


New Operator on page 3-222, Nothing Function on page 3-224, Object Class on
page 3-231, and Typeof Function on page 3-356

GetPicklistBusComp Method

GetPicklistBusComp returns the pick business component associated with the


specified field in the current business component. This method is used with
business component objects. For details, see the Siebel Object Interfaces Reference.

GetProfileAttr Method

GetProfileAttr returns the value of an attribute in a user profile.For details, see the
Siebel Object Interfaces Reference.

Version 6.0

Siebel VB Language Reference

3-141

Siebel VB Language Reference


GetProperty Method

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

GetSearchExpr returns the current search expression for a Siebel business


component. This method is used with business component objects. For details, see
the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GetType Method

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

GetUserProperty returns the value of a named UserProperty. This method is used


with business component objects. For details, see the Siebel Object Interfaces
Reference.

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

Siebel VB Language Reference

3-143

Siebel VB Language Reference


Global Statement

Global Statement

This standard VB statement declares Global variables for use in a Basic program.
Syntax

Global variableName [As type] [,variableName [As type]] ...


Argument

Description

variableName

A variable name

type

The variables data 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Global Statement

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]

where subscriptRange is of the format:


[startSubscript To] endSubscript

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

Siebel VB Language Reference

3-145

Siebel VB Language Reference


Global Statement

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

Variant variables are initialized to vartype Empty.


Example

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Global Statement

Global acctno as Integer


Global total as Integer
Global grecord as acctrecord
Declare Sub CreateFile
Sub CreateFile
Dim x
x = 1
grecord.acctno = 1
Open "c:\temp001" For Output as #1
Do While grecord.acctno <> 0
grecord.acctno = InputBox("Enter 0 or new account #" _
& x & ":")
If grecord.acctno <> 0 then
Print #1, grecord.acctno
x = x + 1
End If
Loop
total = x-1
Close #1
End Sub
Sub Button_Click
Dim msgtext
Dim newline as String
newline = Chr$(10)
Call CreateFile
Open "c:\temp001" For Input as #1
msgtext = "The new account numbers are: " & newline
For x = 1 to total
Input #1, grecord.acctno
msgtext = msgtext & newline & grecord.acctno
Next x
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub

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

Siebel VB Language Reference

3-147

Siebel VB Language Reference


GoTo Statement

GoTo Statement

This standard VB method transfers program control to a specified label.


Syntax

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


GoTo Statement

NOTE: It is considered good programming practice to avoid the use of GoTo


statements. When possible, other constructs should be used to accomplish the same
end. For example, the previous example could be reworked so that the If statement
appears in a separate function called by the main program. If the test failed, the
initial routine could be called again. The following example demonstrates this
alternative.

(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

Do...Loop Statement on page 3-81, FindActiveXControl Method on page 3-108,


If...Then...Else Statement on page 3-154, Select Case Statement on page 3-288, and
While...Wend Statement on page 3-369

Siebel VB Language Reference

3-149

Siebel VB Language Reference


GotoApplet Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Hex Function

Hex Function

This standard VB function returns the hexadecimal representation of a number, as


a string.
Syntax

Hex[$](number)
Argument

Description

number

Any numeric expression

Returns

The hexadecimal representation of number as a string.

Usage

If number is an integer, the return string contains up to four hexadecimal digits;


otherwise, the value will be converted to a long integer, and the string can contain
up to 8 hexadecimal digits.
To represent a hexadecimal number directly, precede the hexadecimal value with
&H. For example, &H10 equals decimal 16 in hexadecimal notation.
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 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

Format Function on page 3-114 and Oct Function on page 3-233

Siebel VB Language Reference

3-151

Siebel VB Language Reference


Hour Function

Hour Function

This standard VB function returns the hour-of-day component (023) of a date-time


value.
Syntax

Hour(time)
Argument

Description

time

Any numeric or string expression that can evaluate to a date-time or


time value

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Hour Function

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

Date Statement on page 3-62, DateSerial Function on page 3-64, DateValue


Function on page 3-65, Day Function on page 3-67, 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 Statement on page 3-345, 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

Siebel VB Language Reference

3-153

Siebel VB Language Reference


If...Then...Else Statement

If...Then...Else Statement

This standard VB control structure executes alternative blocks of program code


based on one or more expressions.
Syntax A

If condition Then then_statement [ Else else_statement ]

Syntax B

If condition Then
statement_block
[ElseIf expression Then
statement_block ]...
[Else
statement_block ]
End If
Placeholder

Description

condition

Any expression that evaluates to TRUE (non-zero) or FALSE (zero)

then_statement

Any valid single expression

else statement

Any valid single expression

expression

Any expression that evaluates to TRUE (non-zero) or FALSE (zero)

statement_block

0 or more valid expressions, separated by colons (:), or on different


lines

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


If...Then...Else Statement

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

Do...Loop Statement on page 3-81, FindActiveXControl Method on page 3-108,


GoTo Statement on page 3-148, On...GoTo Statement on page 3-234, Select Case
Statement on page 3-288, and While...Wend Statement on page 3-369

Siebel VB Language Reference

3-155

Siebel VB Language Reference


Input Function

Input Function

This standard VB function returns a string containing the characters read from a file.
Syntax

Input[$](number, [#]filenumber)
Argument

Description

number

An integer representing the number of characters (bytes) to read from


the file

filenumber

The number identifying the open file to use

Returns

The data read from the file, as a string.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Input Function

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

Siebel VB Language Reference

3-157

Siebel VB Language Reference


Input Statement

Input Statement

This standard VB statement reads data from a sequential file and assigns the data
to variables.
Syntax A

Input [#]filenumber, variable[, variable]...

Syntax B

Input [prompt,] variable[, variable]...


Argument

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

An optional string that prompts for keyboard input

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Input Statement

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

Siebel VB Language Reference

3-159

Siebel VB Language Reference


InputBox Function

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

InputBox[$](prompt, [title,] [defaultText,] [xpos,] [ypos])


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).
Argument

Description

prompt

A string expression containing the text to show in the dialog box

title

A string expression containing the caption to display in the dialog boxs


title bar

defaultText

A string expression to display in the edit box as the default response

xpos

An integer expression, specified in dialog box units, that determines the


position of the left side of the dialog box

ypos

An integer expression, specified in dialog box units, that determines the


position of the top of the dialog box

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


InputBox Function

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

Whatever is entered by the user


Caution: When used within a Siebel application, the title is

overridden by the application, and the contents of title are ignored.

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.

Siebel VB Language Reference

3-161

Siebel VB Language Reference


InputBox Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


InStr Function

InStr Function

This standard VB function returns the position of the first occurrence of one string
within another string.
Syntax A

InStr([start,] string1, string2)

Syntax B

InStr(start, string1, string2[, compare])


Argument

Description

start

An integer representing the position in string1 to begin the search, with the
first character in the string as 1

string1

The string to search

string2

The string to find

compare

0 if a case-sensitive search is desired


1 if a case-insensitive search is desired

Returns

The position of the first character of string2 in string1.

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:

 start is greater than the length of string2.


 string1 is a null string.
 string2 is not found.
If either string1 or string2 is a null variant, Instr returns a null variant.
If string2 is a null string (""), Instr returns the value of start.

Version 6.0

Siebel VB Language Reference

3-163

Siebel VB Language Reference


InStr Function

If compare is 0, a case-sensitive comparison based on the ANSI character set


sequence is performed. If compare is 1, a case-insensitive comparison is done based
upon the relative order of characters as determined by the country code setting for
your system. If compare is omitted, the module level default, as specified with
Option Compare, is used.
Example

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


InStr Function

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

Siebel VB Language Reference

3-165

Siebel VB Language Reference


Int Function

Int Function

This standard VB function returns the integer part of a number.


Syntax

Int(number)
Argument

Description

number

Any numeric expression

Returns

The integer part of number.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Int Function

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

Siebel VB Language Reference

3-167

Siebel VB Language Reference


InvokeMethod Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IPmt Function

IPmt Function

This standard VB function returns the interest portion of a payment for a given
period of an annuity.
Syntax

IPmt(rate, period, nper, pv, fv, due)


Argument

Description

rate

Interest rate per period

period

The specific payment period, in the range 1 through nper

nper

The total number of payment periods

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

0 if payments are due at the end of the payment period


1 if payments are due at the beginning of the payment period

Returns

The interest portion of a payment for a given payment period.

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

Siebel VB Language Reference

3-169

Siebel VB Language Reference


IPmt Function

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

FV Function on page 3-130, 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IRR Function

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( )

An array containing cash-flow values

guess

An estimate of the value returned by IRR

Returns

The internal rate of return for a stream of periodic cash flows.

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

Siebel VB Language Reference

3-171

Siebel VB Language Reference


IRR Function

Example

This example calculates an internal rate of return (expressed as an interest rate


percentage) for a series of business transactions (income and costs). The first value
entered must be a negative amount, or IRR generates an Illegal Function Call
error.
Sub Button_Click
Dim cashflows() as Double
Dim guess, count as Integer
Dim i as Integer
Dim intnl as Single
Dim msgtext as String
guess = .15
count = InputBox("How many cash flow amounts do you have?")
ReDim cashflows(count + 1)
For i = 0 to count-1
cashflows(i) = InputBox("Enter income value for month "_
& i + 1 & ":")
Next i
intnl = IRR(cashflows(),guess)
msgtext = "The IRR for your cash flow amounts is: "
msgtext = msgtext & Format(intnl, "Percent")
MsgBox msgtext
End Sub

See Also

3-172

FV Function on page 3-130, IPmt Function on page 3-169, 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Is Operator

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

Any valid object expression

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

CreateObject Function on page 3-50, GetObject Function on page 3-139, Me on


page 3-206, Nothing Function on page 3-224, Object Class on page 3-231, and
Typeof Function on page 3-356

Version 6.0

Siebel VB Language Reference

3-173

Siebel VB Language Reference


IsDate Function

IsDate Function

This standard VB function indicates whether or not an expression is a legal date.


Syntax

IsDate(expression)
Argument

Description

expression

Any valid expression

Returns

-1 (TRUE) if expression is a legal date, 0 (FALSE) if it is not.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IsEmpty Function

IsEmpty Function

This standard VB function is used to determine whether a variable of data type


variant has been initialized.
Syntax

IsEmpty(expression)
Argument

Description

expression

Any expression containing a variable of data type variant

Returns

-1 (TRUE) if a variant has been initialized; 0 (FALSE) otherwise.

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

Siebel VB Language Reference

3-175

Siebel VB Language Reference


IsEmpty Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IsMissing Function

IsMissing Function

This standard VB function is used to determine whether an optional argument for


a procedure has been supplied by the caller.
Syntax

IsMissing(argname)
Argument

Description

argname

An optional argument for a subprogram, function, Siebel VB statement, or


Siebel VB function

Returns

-1 (TRUE) if an optional parameter was not supplied by the user; 0 (FALSE)


otherwise.

Usage

IsMissing is used in procedures that have optional arguments to find out whether
the arguments value was supplied or not.

Version 6.0

Siebel VB Language Reference

3-177

Siebel VB Language Reference


IsMissing Function

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

Function...End Function Statement on page 3-127

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IsNull Function

IsNull Function

This standard VB function is used to determine whether a variant variable has the
Null value.
Syntax

IsNull(expression)
Argument

Description

expression

Any expression containing a variable of data type variant

Returns

-1 (TRUE) if a variant expression contains the Null value, 0 (FALSE) otherwise.

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

Siebel VB Language Reference

3-179

Siebel VB Language Reference


IsNull Function

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

IsDate Function on page 3-174, IsEmpty Function on page 3-175, IsNumeric


Function on page 3-181, and VarType Function on page 3-363

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


IsNumeric Function

IsNumeric Function

This standard VB function is used to determine whether the value of a variable is


numeric.
Syntax

IsNumeric(expression)
Argument

Description

expression

Any valid expression

Returns

-1 (TRUE) if expression has a data type of Numeric, 0 (FALSE) otherwise

Usage

IsNumeric returns -1 (TRUE) if the expression is of vartypes 2-6 (numeric) or a


string that can be interpreted as a number.
Any input in an InputBox is of type string. If numeric input is required, IsNumeric
can be used to determine whether the value input by the user is a valid number
before converting the input to a numeric data type for processing.

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

Siebel VB Language Reference

3-181

Siebel VB Language Reference


IsNumeric Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Kill Statement

Kill Statement

Deletes files from a hard disk or floppy drive.


Syntax

Kill pathname
Argument

Description

pathname

A string expression that represents a valid DOS file specification

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

Siebel VB Language Reference

3-183

Siebel VB Language Reference


LastRecord Method

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

FileAttr Function on page 3-101, FileDateTime Function on page 3-105, GetAttr


Function on page 3-135, and RmDir Statement on page 3-275

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


LBound Function

LBound Function

This standard VB function returns the lower bound of the subscript range for an
array.
Syntax

LBound( arrayname [, dimension] )


Argument

Description

arrayname

The name of the array to query

dimension

The dimension to query

Returns

The lower bound (lowest index number) of dimension dimension of arrayname.

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

Siebel VB Language Reference

3-185

Siebel VB Language Reference


LBound Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


LCase Function

LCase Function

This standard VB function returns a lowercase copy of a string.


Syntax

LCase[$](string)
Argument

Description

string

A string or an expression containing a string

Returns

A copy of string, with all uppercase letters converted to lowercase.

Usage

The substitution of characters is based on the country specified in the Windows


Control Panel. LCase accepts expressions of type string. LCase 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 will typically return a variant of vartype 8 (string).
If the value of string is NULL, a variant of vartype 1 (Null) is returned.
The LCase or UCase function is useful for comparing string data when you need to
compare the actual text values, but the case in which input is entered is irrelevant.

Example

This example converts a string entered by the user to lowercase.


Sub Button_Click
Dim userstr as String
userstr = InputBox$("Enter a string in upper and lowercase _
letters")
userstr = LCase$(userstr)
Msgbox "The string now is: " & userstr
End Sub

See Also

Version 6.0

UCase Function on page 3-359

Siebel VB Language Reference

3-187

Siebel VB Language Reference


Left Function

Left Function

This standard VB function returns a string of a specified length copied from the
beginning of another string.
Syntax

Left[$]( string, length)


Argument

Description

string

A string, or an expression containing a string, from which a portion is to be


copied

length

An integer representing the number of characters to copy

Returns

A substring of string, of length length, beginning at the first character of string.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Left Function

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

Siebel VB Language Reference

3-189

Siebel VB Language Reference


Len Function

Len Function

This standard VB function returns the length of a string or string variable.


Syntax A

Len(string)

Syntax B

Len(varName)
Argument

Description

string

A string or an expression that evaluates to a string

varName

A variable that contains a string

Returns

The length of string or the string contained in the variable varName.

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

InStr Function on page 3-163

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Let (Assignment Statement)

Let (Assignment Statement)

The Let statement is a standard VB statement that assigns an expression to a Basic


variable.
Syntax

[Let] variable = expression


Placeholder

Description

variable

The variable to which a value is to be assigned

expression

The expression containing the value to be assigned to variable

Returns

Not applicable

Usage

The keyword Let is optional.


The Let statement can be used to assign a value or expression to a variable with a
data type of numeric, string, variant, or record variable. You can also use the Let
statement to assign to a record field or to an element of an array.
When assigning a value to a numeric or string variable, standard conversion rules
apply.
Let differs from Set in that Set assigns a variable to a COM object. For example,
Set o1 = o2 will set the object reference.
Let o1 = o2 will set the value of the default member.

Version 6.0

Siebel VB Language Reference

3-191

Siebel VB Language Reference


Let (Assignment Statement)

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

Const Statement on page 3-47, Lset Statement on page 3-203, and


Service_InvokeMethod Event on page 3-294

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Like Operator

Like Operator

Like is a standard VB operator used to compare the contents of string expressions.


Syntax

string LIKE pattern


Placeholder

Description

string

Any string or string expression

pattern

Any string expression to compare to string

Returns

-1 (TRUE) if string matches pattern, 0 (FALSE) otherwise.

Usage

pattern can include the following special characters:


Character

Matches

A single character

A set of zero or more characters

A single digit character (09)

[chars]

A single character in chars

[!chars]

A single character not in chars

[startcharendchar]

A single character in the range startchar to endchar

[!startcharendchar]

A single character not in the range startchar to endchar

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

Siebel VB Language Reference

3-193

Siebel VB Language Reference


Like Operator

Example

This example tests whether a letter is lowercase.


Sub Button_Click
Dim userstr as String
Dim revalue as Integer
Dim msgtext as String
Dim pattern
pattern = "[a-z]"
userstr = InputBox$("Enter a letter:")
retvalue = userstr LIKE pattern
If retvalue = -1 then
msgtext = "The letter " & userstr & " is lowercase."
Else
msgtext = "Not a lowercase letter."
End If
Msgbox msgtext
End Sub

See Also

3-194

InStr Function on page 3-163, Option Compare Statement on page 3-244, and
StrComp Function on page 3-332

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Line Input Statement

Line Input Statement

This standard VB statement reads a line from a sequential file into a string variable.
Syntax A

Line Input [#] filenumber, varName

Syntax B

Line Input [prompt,] varName


Argument

Description

filenumber

The file number, given in the Open statement, of the open file from which
to read

varName

A string variable into which a line of data or user input is to be read

prompt

A string literal prompting for keyboard input

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

Siebel VB Language Reference

3-195

Siebel VB Language Reference


Line Input Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Loc Function

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

Siebel VB Language Reference

3-197

Siebel VB Language Reference


Lock Statement

Lock Statement

This standard VB statement controls access to an open file.


Syntax

Lock [#]filenumber[, [start] [To end]]


Argument

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Lock Statement

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

Open Statement on page 3-238 and Unlock Statement on page 3-361

Siebel VB Language Reference

3-199

Siebel VB Language Reference


Lof Function

Lof Function

This standard VB function returns the length in bytes of an open file.


Syntax

Lof(filenumber)
Argument

Description

filenumber

The number of the open file, as used in the Open statement

Returns

The length of the open file, in bytes.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Log Function

Log Function

This standard VB function returns the natural logarithm of a number.


Syntax

Log(number)
Argument

Description

number

Any valid numeric expression

Returns

The natural logarithm of number.

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

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

Siebel VB Language Reference

3-201

Siebel VB Language Reference


LoginId Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Lset Statement

Lset Statement

This standard VB statement copies one string to another or assigns a user-defined


type variable to another.
Syntax A

Lset string = string-expression

Syntax B

Lset variable1 = variable2


Argument

Description

string

A string variable or string expression to contain the copied characters

string-expression

A string variable or string expression containing the string to be


copied

variable1

A variable within a user-defined type to contain the copied variable

variable2

A variable containing a user-defined type to be copied

Returns

Not applicable

Usage

If string is shorter than string-expression, Lset copies the leftmost characters of


string-expression into string. The number of characters copied is equal to the length
of string.
If string is longer than string-expression, all characters of string-expression are
copied into string, filling it from left to right. All leftover characters in string are
replaced with spaces.
In Syntax B, the number of characters copied is equal to the length of the shorter of
variable1 and variable2.
Lset cannot be used to assign variables of different user-defined types if either
contains a variant or a variable-length string.

Version 6.0

Siebel VB Language Reference

3-203

Siebel VB Language Reference


Lset Statement

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

Rset Statement on page 3-279

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


LTrim Function

LTrim Function

This standard VB function returns a string with all leading spaces removed.
Syntax

LTrim[$](string)
Argument

Description

string

A string or string expression containing the string to be trimmed

Returns

A copy of string with all leading space characters removed.

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

Siebel VB Language Reference

3-205

Siebel VB Language Reference


Me

Me

Me is standard VB shorthand used to refer to the currently used object.


Syntax A

With Me
.methodname() statement
End With

Syntax B

Me.methodname() statement
Placeholder

Description

methodname

The name of the method to be used with the object

statement

The code to be executed, or the arguments to the method

Returns

Not applicable

Usage

Some Siebel VB modules are attached to application objects, and Siebel VB


subroutines are invoked when that application object encounters events. For
example, Me may refer to a button that triggers a Basic routine when the user clicks
on it, or when a method is invoked on an application object by a program
statement.
Subroutines in such contexts can use the variable Me to refer to the object that
triggered the event (for example, the button that was clicked). The programmer can
use Me in all the same ways as any other object variable, except that Me cannot be
Set.

Example

For examples, see Service_InvokeMethod Event on page 3-294 and With


Statement on page 3-372.

See Also

CreateObject Function on page 3-50, GetObject Function on page 3-139, New


Operator on page 3-222, Nothing Function on page 3-224, Object Class on
page 3-231, and Typeof Function on page 3-356

3-206

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Mid Function

Mid Function

This standard VB function returns a portion of a string, starting at a specified


location within the string.
Syntax

Mid[$](string, start[, length])


Argument

Description

string

A string or string expression containing the string to be copied

start

An integer representing the starting position in string to begin copying


characters

length

An integer representing the number of characters to copy

Returns

A substring of string, of length length, beginning at the start character of string.

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

Siebel VB Language Reference

3-207

Siebel VB Language Reference


Mid Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Mid Statement

Mid Statement

Mid replaces part (or all) of one string with another, starting at a specified location.
Syntax

Mid (stringVar, start[, length]) = string


Argument

Description

stringVar

The string to be changed

start

An integer representing the position in stringVar at which to begin


replacing characters

length

An integer representing the number of characters to replace

string

The string to place into stringVar

Returns

The value of stringVar with string embedded at the specified location.

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

Siebel VB Language Reference

3-209

Siebel VB Language Reference


Mid Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Minute Function

Minute Function

This standard VB function returns the minute component (059) of a date-time


value.
Syntax

Minute(time)
Argument

Description

time

Any numeric or string expression that can evaluate to a date-time or


time value

Returns

If the expression evaluates to a date-time or time value, the minute component of


that value; otherwise 0.

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

Siebel VB Language Reference

3-211

Siebel VB Language Reference


Minute Function

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

Date Statement on page 3-62, DateSerial Function on page 3-64, DateValue


Function on page 3-65, Day Function on page 3-67, Hour Function on page 3-152,
Month Function on page 3-214, Now Function on page 3-226, Second Function on
page 3-282, Time Statement on page 3-345, 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


MkDir Statement

MkDir Statement

This standard VB statement creates a new directory.


Syntax

MkDir [drive:][\directory\]directory
Argument

Description

drive:

(Optional) The name of the drive on which the directory is to be created,


as a letter, or a string expression representing the drive name

\directory\

If the directory is not to be created on the current directory of the specified


drive (or the default drive if none is specified), the path to the directory in
which the new directory is to be created, or a string expression representing
the path

directory

The name of the directory to be created, or a string expression representing


the directory name

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

Siebel VB Language Reference


Month Function

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

Any numeric or string expression that can evaluate to a date-time or date


value

Returns

If the expression evaluates to a date-time or date value, the month component of


that value; otherwise 0.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Month Function

See Also

Version 6.0

Date Statement on page 3-62, DateSerial Function on page 3-64, DateValue


Function on page 3-65, Day Function on page 3-67, Hour Function on page 3-152,
Minute Function on page 3-211, Now Function on page 3-226, Second Function on
page 3-282, Time Statement on page 3-345, 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

Siebel VB Language Reference

3-215

Siebel VB Language Reference


Msgbox Function

Msgbox Function

This standard VB method can operate either as a function or a statement. As a


function it displays a message dialog box and returns a value indicating which
button the user selected.
Syntax A
(Function)

Msgbox(prompt[, buttons][, title])

Syntax B
(Statement)

MsgBox prompt [, buttons][, title$]

Returns

3-216

Argument

Description

prompt

A string expression representing the text to display in the message box

buttons

An integer indicating the combination of buttons, icon, and default button


to display in the message box

title

The caption to display in the title bar of the message box

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Msgbox Function

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

Abort, Retry, Ignore

Yes, No, Cancel

Yes, No

Retry, Cancel

Group 2:

16

Critical Message (STOP)

Icons

32

Warning Query ( ? )

48

Warning Message ( ! )

64

Informational Message ( i )

Group 3:

First button

Default
Button

256

Second button

512

Third button

If buttons is omitted, MsgBox displays a single OK button.

Version 6.0

Siebel VB Language Reference

3-217

Siebel VB Language Reference


Msgbox Function

Example

This example displays one of each type of message box.


Sub Button_Click
Dim btngrp as Integer, icongrp as Integer, defgrp as Integer
Dim msgtext as String
icongrp = 16
defgrp = 0
btngrp = 0
Do Until btngrp = 6
Select Case btngrp
Case 1, 4, 5
defgrp = 0
Case 2
defgrp = 256
Case 3
defgrp = 512
End Select
msgtext = "Icon group = " & icongrp & Chr(10) _
& "Button group = " & btngrp & Chr(10) _
& "Default group = " & defgrp & Chr(10)
msgtext = msgtext & Chr(10) & "Continue?"
answer = MsgBox(msgtext, btngrp + icongrp + defgrp)
Select Case answer
Case 2,3,7
Exit Do
End Select
If icongrp <> 64 then
icongrp = icongrp + 16
End If
btngrp = btngrp + 1
Loop
End Sub

See Also

3-218

InputBox Function on page 3-160

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


MsgBox Method

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

Siebel VB Language Reference

3-219

Siebel VB Language Reference


Name Statement

Name Statement

This standard VB statement renames a file or copies a file from one directory to
another.
Syntax

Name [path1\]oldfilename As [path2\]newfilename


Argument

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

A string expression containing the name of the file to be renamed

path2\

A string expression containing the path to the location where the


renamed file should appear; if a path is not given, the file will appear in
the current directory of the current drive

newfilename

A string expression containing the new name for the file

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Name Statement

Example

This example creates a temporary file, c:\temp001, renames the file to


c:\temp002, then deletes them both. It calls the subprogram CreateFile to
create the c:\temp001 file.
(general) (declarations)
Option Explicit
Declare Sub CreateFile
Sub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Dim y()
Dim startletter
Open "C:\TEMP001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End Sub
Sub Button_Click
Call CreateFile
On Error Resume Next
Name "C:\TEMP001" As "C:\TEMP002"
MsgBox "The file has been renamed"
MsgBox "Now deleting both files"
Kill "TEMP001"
Kill "TEMP002"
End Sub

See Also

Version 6.0

FileAttr Function on page 3-101, FileCopy Statement on page 3-103, GetAttr


Function on page 3-135, and Kill Statement on page 3-183

Siebel VB Language Reference

3-221

Siebel VB Language Reference


New Operator

New Operator

The New operator allocates and initializes a new COM object of the named class.
Syntax

Set objectVar = New className


Dim objectVar As New className
Argument

Description

objectVar

The COM object to allocate and initialize

className

The class to assign to the object

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

if objectVar is Set to Nothing and referenced again.

See Also

3-222

Dim Statement on page 3-73, Global Statement on page 3-144,


Service_InvokeMethod Event on page 3-294, and Static Statement on page 3-328

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


NewPropertySet Method

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

Siebel VB Language Reference

3-223

Siebel VB Language Reference


Nothing Function

Nothing Function

This standard VB function removes an instantiated object from memory.


Syntax

Set objectName = Nothing


Argument

Description

objectName

The name of the object variable to set to Nothing

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Nothing Function

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

Siebel VB Language Reference

3-225

Siebel VB Language Reference


Now Function

Now Function

This standard VB function returns the current date and time.


Syntax

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


NPV Function

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

The discount rate per period

valuearray( )

An array containing cash-flow values

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

Siebel VB Language Reference

3-227

Siebel VB Language Reference


NPV Function

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

FV Function on page 3-130, IPmt Function on page 3-169, IRR Function on


page 3-171, 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Null Function

Null Function

This standard VB function sets a variant variable to the Null value.


Syntax

Null
Argument

Description

Not applicable

Returns

A variant value set to NULL.

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

Siebel VB Language Reference

3-229

Siebel VB Language Reference


Null Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Object Class

Object Class

Object is a class that provides access to COM automation objects.


Syntax

Dim variableName As Object


Placeholder

Description

variableName

The name of the object variable to declare

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

Siebel VB Language Reference

3-231

Siebel VB Language Reference


Object Class

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
'
'
'
'

BusObject returns the business object associated with a


control or applet.
GetBusComp returns a reference to a Siebel
business component that is in the UI context

set oBC = me.BusObject.GetBusComp("Contact")


i = oBC.FirstRecord ' returns 0 if fails, 1 if succeeds
if i <> 1 then
MsgBox("Error accessing contact records for the account")
else
icount = 0
' NextRecord will return 1 if it succesfully
' moved to the next record in the BC
While i = 1
icount = icount + 1
i = oBC.NextRecord ' returns 1 if successful
wend
MsgBox("Total Records = " & str(icount))
oBC.FirstRecord
end if
End Sub

See Also

3-232

CreateObject Function on page 3-50, GetObject Function on page 3-139, New


Operator on page 3-222, Nothing Function on page 3-224, and Typeof Function on
page 3-356

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Oct Function

Oct Function

This standard VB function converts a number to an octal (base 8) number.


Syntax

Oct[$](number)
Argument

Description

number

Any numeric expression

Returns

The octal representation of a number, as a string.

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, &O10 equals decimal 8 in octal notation.

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

Hex Function on page 3-151

Siebel VB Language Reference

3-233

Siebel VB Language Reference


On...GoTo Statement

On...GoTo Statement

This standard VB programming control structure causes execution to branch to a


label in the current procedure based on the value of a numeric expression.
Syntax

On number GoTo label1[, label2, ... ]


Argument

Description

number

Any numeric expression that evaluates to a positive number

label1, label2, ...

A label in the current procedure to branch to if number evaluates to


1, 2, and so on

Returns

Not applicable

Usage

If number evaluates to 0 or to a number greater than the number of labels following


GoTo, the program continues at the next statement. If number evaluates to a
number less than 0 or greater than 255, an Illegal function call error is issued.

Example

This example branches to different points in the current procedure based on a


number entered by the user.
Sub Button_Click
Dim answer as Integer
answer = InputBox("Enter a choice (1-3) or 0 to quit")
On answer GoTo c1, c2, c3
MsgBox("You typed 0.")
Exit Sub
c1:
MsgBox("You picked choice 1.")
Exit Sub
c2:
MsgBox("You picked choice 2.")
Exit Sub
c3:
MsgBox("You picked choice 3.")
Exit Sub
End Sub

See Also

3-234

GoTo Statement on page 3-148 and Select Case Statement on page 3-288

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


On Error Statement

On Error Statement

This standard VB statement specifies the location of an error-handling routine


within the current procedure.
Syntax

On Error {GoTo label | Resume Next | GoTo 0}

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

Enables the error-handling routine that starts at label. If the designated


label is not in the same procedure as the On Error statement, Siebel VB
generates an error message.

Resume Next

Designates that error-handling code is handled by the statement that


immediately follows the statement that caused an error. At this point,
use the Err function to retrieve the error code of the run-time error.

GoTo 0

Disables any error handler that has been enabled.

When it is referenced by an On Error GoTo label statement, an error handler is


enabled. Once this enabling occurs, a run-time error will result in program control
switching to the error-handling routine and activating the error handler. The error
handler remains active from the time the run-time error has been trapped until a
Resume statement is executed in the error handler.
If another error occurs while the error handler is active, Siebel VB will search for an
error handler in the procedure that called the current procedure (if this fails, Siebel
VB will look for a handler belonging to the callers caller, and so on). If a handler
is found, the current procedure will terminate, and the error handler in the calling
procedure will be activated.

Version 6.0

Siebel VB Language Reference

3-235

Siebel VB Language Reference


On Error Statement

NOTE: Because Siebel VB searches in the caller for an error handler, any additional

On Error statements in the original error handler will be ignored.


It is an error (No Resume) to execute an End Sub or End Function statement while
an error handler is active. The Exit Sub or Exit Function statement can be used to
end the error condition and exit the current procedure.
Example

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


On Error Statement

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

Siebel VB Language Reference

3-237

Siebel VB Language Reference


Open Statement

Open Statement

This standard VB statement opens a file for input or output.


Syntax

Open filename [For mode] [Access access] [lock] As [#]filenumber [Len = reclen]
Argument

Description

filename

A string or string expression representing the name of the file to open

mode

A keyword indicating the purpose for which the file is opened

access

A keyword indicating the method of access to the file

lock

A keyword designating the access method allowed to the file by other


processes

filenumber

An integer used to identify the file while it is open

reclen

In a Random or Binary file, the length of the records

Returns

A file opened in the specified manner.

Usage

The following keywords are used for mode, access, and lock:
Keyword

Consequences

Mode Keywords

3-238

Input

Puts data into the file sequentially

Output

Reads data from the file sequentially

Append

Adds data to the file sequentially

Random

Gets data from the file by random access

Binary

Gets binary data from the file

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Open Statement

Keyword

Consequences

Access Keywords
Read

Reads data from the file only

Write

Writes data to the file only

Read Write

Reads or writes data to the file

Lock Keywords
Shared

Read or write is available on the file

Lock Read

Only read is available

Lock Write

Only write is available

Lock Read Write

No read or write is available

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

Siebel VB Language Reference

3-239

Siebel VB Language Reference


Open Statement

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

Close Statement on page 3-45 and FreeFile Function on page 3-126

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Option Base Statement

Option Base Statement

This standard VB statement specifies the default lower bound to use for array
subscripts.
Syntax

Option Base lowerBound


Placeholder

Description

lowerBound

Either 0 or 1 or an expression that evaluates to one of these values

Returns

Not applicable

Usage

If no Option Base statement is specified, the default lower bound for array
subscripts will be 0.

Version 6.0

Siebel VB Language Reference

3-241

Siebel VB Language Reference


Option Base Statement

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

Placing declarations in the (general) (declarations) section

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Option Base Statement

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

Siebel VB Language Reference

3-243

Siebel VB Language Reference


Option Compare Statement

Option Compare Statement

This standard VB statement specifies the default method for string comparisons:
either case-sensitive or case-insensitive.
Syntax

Option Compare { Binary | Text }


Argument

Description

Not applicable

Returns

Not applicable

Usage

The Option Compare statement must be placed in the (general) (declarations)


section in the Siebel VB Editor, as shown in Figure 3-4 on page 3-242.
Binary comparisons are case-sensitive (that is, lowercase and uppercase letters are
different). Text comparisons are not case-sensitive.
Binary comparisons compare strings based upon the ANSI character set. Text
comparisons are based upon the relative order of characters as determined by the
country code setting for your system.

3-244

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Option Compare Statement

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

InStr Function on page 3-163 and StrComp Function on page 3-332

Siebel VB Language Reference

3-245

Siebel VB Language Reference


Option Explicit Statement

Option Explicit Statement

This standard VB statement specifies that all variables in a module must be


explicitly declared.
Syntax

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Option Explicit Statement

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

Siebel VB Language Reference

3-247

Siebel VB Language Reference


ParentBusComp Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Pmt Function

Pmt Function

This standard VB function returns a constant periodic payment amount for an


annuity or a loan.
Syntax

Pmt(rate, nper, pv, fv, due)


Argument

Description

rate

The interest rate per period

nper

The total number of payment periods

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

0 if due at the end of each period


1 if due at the beginning of each period

Returns

The constant periodic payment amount.

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

Siebel VB Language Reference

3-249

Siebel VB Language Reference


Pmt Function

Example

This example finds the monthly payment on a given loan.


Sub Button_Click
Dim aprate, totalpay
Dim loanpv, loanfv
Dim due, monthlypay
Dim yearlypay, msgtext
loanpv = InputBox("Enter the loan amount: ")
aprate = InputBox("Enter the loan rate percent: ")
If aprate >1 then
aprate = aprate/100
End If
totalpay = InputBox("Enter the total number of monthly _
payments: ")
loanfv = 0
'Assume payments are made at end of month
due = 0
monthlypay = Pmt(aprate/12,totalpay,-loanpv,loanfv,due)
msgtext = "The monthly payment is: " & _
Format(monthlypay, "Currency")
MsgBox msgtext
End Sub

See Also

3-250

FV Function on page 3-130, IPmt Function on page 3-169, IRR Function on


page 3-171, NPV Function on page 3-227,PPmt Function on page 3-252, PV
Function on page 3-258, and Rate Function on page 3-261

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


PositionId Method

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

Siebel VB Language Reference

3-251

Siebel VB Language Reference


PPmt Function

PPmt Function

This standard VB function returns the principal portion of the payment for a given
period of an annuity.
Syntax

PPmt(rate, per, nper, pv, fv, due)


Argument

Description

rate

The interest rate per period

per

The payment period, in the range from 1 to nper

nper

The total number of payment periods

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

0 if due at the end of each period


1 if due at the beginning of each period

Returns

The principal portion of the payment for a given period.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


PreviousRecord Method

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

FV Function on page 3-130, IPmt Function on page 3-169, IRR Function on


page 3-171, NPV Function on page 3-227, PPmt Function on page 3-252, PV
Function on page 3-258, and Rate Function on page 3-261

PreviousRecord Method

PreviousRecord moves to the previous 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.

Version 6.0

Siebel VB Language Reference

3-253

Siebel VB Language Reference


Print Statement

Print Statement

This standard VB method prints data to an open file or to the screen.


Syntax

Print [#][filenumber,] expressionList [{;|, }]


Argument

Description

filenumber

The number of the open file to print to

expressionList

A list of values to be printed, in the form of literals or expressions

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


PropertyExists Method

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

PropertyExists returns a Boolean value indicating whether a specified property


exists in a property set. For details, see the Siebel Object Interfaces Reference.

Version 6.0

Siebel VB Language Reference

3-255

Siebel VB Language Reference


Put Statement

Put Statement

This standard VB statement writes a variable to a file opened in random or binary


mode.
Syntax

Put [#]filenumber, [ recnumber], varName


Argument

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

The name of the variable containing the data to write

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Put Statement

 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:

 Put writes variables to the disk without record padding.


 Variable length Strings that are not part of user defined types are not preceded
by the two byte string length.
Example

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

Siebel VB Language Reference

3-257

Siebel VB Language Reference


PV Function

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

PV(rate, nper, pmt, fv, due)


Argument

Description

rate

The interest rate per period

nper

The total number of payment periods

pmt

The constant periodic payment per period

fv

The future value of the final lump sum amount required (as with a savings
plan) or paid (0 as with a loan)

due

0 if due at the end of each period


1 if due at the beginning of each period

Returns

The present value of a constant periodic stream of cash flows.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


PV Function

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

FV Function on page 3-130, 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, and Rate Function on page 3-261

Siebel VB Language Reference

3-259

Siebel VB Language Reference


Randomize Statement

Randomize Statement

This standard VB statement seeds the random number generator.


Syntax

Randomize [number]
Argument

Description

number

An integer value between -32768 and 32767

Returns

Not applicable

Usage

If no number argument is given, Siebel VB uses the Timer function to initialize the
random number generator.

Example

This example generates a random string of characters using the Randomize


statement and Rnd function. 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, y As Integer
Dim str1 As String, 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-260

+ lower)

Rnd Function on page 3-277 and Timer Function on page 3-347

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Rate Function

Rate Function

This standard VB function returns the interest rate per period for an annuity or a
loan.
Syntax

Rate(nper, pmt, pv, fv, due, guess)


Argument

Description

nper

The total number of payment periods

pmt

The constant periodic payment per period

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

0 if due at the end of each period


1 if due at the beginning of each period

guess

An estimate for the rate returned

Returns

The interest rate per period.

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

Siebel VB Language Reference

3-261

Siebel VB Language Reference


Rate Function

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

FV Function on page 3-130, 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, and PV Function on page 3-258

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ReDim Statement

ReDim Statement

This standard VB statement changes the upper and lower bounds of a dynamic
arrays dimensions.
Syntax

ReDim [Preserve] arrayName (lower To upper) [As [ New ] type] , ...


Argument

Description

arrayName

The name of the array to redimension

lower

The new lower bound for the array

upper

The new upper bound for the array

type

The data type for the array elements

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

Siebel VB Language Reference

3-263

Siebel VB Language Reference


ReDim Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


RefineQuery Method

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

Siebel VB Language Reference

3-265

Siebel VB Language Reference


Rem Statement

Rem Statement

This standard VB statement identifies a line of code as a comment in a Basic


program.
Syntax

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

Test this from the Account Contacts View


This code presumes that Account is the parent BusComp
BusObject will return the business object
associated with a control or applet.

Rem GetBusComp here will return a reference


Rem to the BC that is in the UI context.
set oBC = me.BusObject.GetBusComp("Contact")
Rem FirstRecord will position you at the
Rem first record in the business component.
Rem FirstRecord, NextRecord, etcetera, do not return Booleans.
Rem Siebel VB does not have a Boolean data type.
i = oBC.FirstRecord Rem Returns 0 if fails, 1 if succeeds
if i <> 1 then
MsgBox("Error accessing contact records for the account")

3-266

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Rem Statement

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

Siebel VB Language Reference

3-267

Siebel VB Language Reference


RemoveChild() Method

RemoveChild() Method

RemoveChild removes a child property set from a parent property set. For details,
see the Siebel Object Interfaces Reference.

RemoveProperty Method

RemoveProperty removes a property from a business service or a property set. For


details, see the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Reset Statement

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

Siebel VB Language Reference

3-269

Siebel VB Language Reference


Reset Statement

Debugger:
MsgBox "Error " & Err & " occurred. Closing open file."
Reset
Resume done
End Sub

See Also

3-270

Close Statement on page 3-45

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Resume Statement

Resume Statement

This standard VB statement halts an error-handling routine.


Syntax A

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

Siebel VB Language Reference

3-271

Siebel VB Language Reference


Resume Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Right Function

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

A string or string expression containing the characters to copy

length

The number of characters to copy

Returns

A string of length length copied from the end of string.

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

Siebel VB Language Reference

3-273

Siebel VB Language Reference


Right Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


RmDir Statement

RmDir Statement

This standard VB statement removes a directory.


Syntax

RmDir [drive:][\directory\]directory
Argument

Description

drive:

(Optional) The name of the drive from which the directory is to be


removed, as a letter, or a string expression representing the drive name

\directory\

If the directory is to be removed from a directory other than the default


directory of the specified drive (or the default drive if none is specified),
the path to the directory to be removed

directory

The name of the directory to be removed

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

Siebel VB Language Reference

3-275

Siebel VB Language Reference


RmDir Statement

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Rnd Function

Rnd Function

This standard VB function returns a single-precision random number between 0


and 1.
Syntax

Rnd[(number)]
Argument

Description

number

A numeric expression indicating how the random number is to be generated

Returns

A single-precision pseudo-random number between 0 and 1.

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

Siebel VB Language Reference

3-277

Siebel VB Language Reference


Rnd Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Rset Statement

Rset Statement

This standard VB function right-aligns one string inside another string.


Syntax

Rset string = string-expression


Placeholder

Description

string

The string to receive the right-aligned characters

string-expression

The string containing the characters to put into string

Returns

Not applicable

Usage

If string is longer than string-expression, the leftmost characters of string are


replaced with spaces.
If string is shorter than string-expression, only the leftmost characters of stringexpression are copied.
Rset cannot be used to assign variables of different user-defined types.

Version 6.0

Siebel VB Language Reference

3-279

Siebel VB Language Reference


Rset Statement

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

Lset Statement on page 3-203

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


RTrim Function

RTrim Function

This standard VB statement copies a string and removes any trailing spaces.
Syntax

RTrim[$](string)
Argument

Description

string

A string or string expression

Returns

A string with any trailing spaces removed.

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

For an example, see the Rset Statement on page 3-279.

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

Siebel VB Language Reference

3-281

Siebel VB Language Reference


Second Function

Second Function

This standard VB function returns the second component (059) of a date-time


value.
Syntax

Second(time)
Argument

Description

time

Any numeric or string expression that can evaluate to a date-time or


time value

Returns

If the expression evaluates to a date-time or time value, the second component of


that value; otherwise 0.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Second Function

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

Date Statement on page 3-62, DateSerial Function on page 3-64, DateValue


Function on page 3-65, 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, Time Statement on page 3-345, 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

Siebel VB Language Reference

3-283

Siebel VB Language Reference


Seek Function

Seek Function

This standard VB function returns the current file position for an open file.
Syntax

Seek(filenumber)
Argument

Description

filenumber

The number assigned to the file to be queried in the Open statement

Returns

The position in the file for the next operation.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Seek Function

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

Siebel VB Language Reference

3-285

Siebel VB Language Reference


Seek Statement

Seek Statement

Seek sets the position within an open file for the next read or write operation.
Syntax

Seek [#]filenumber, position


Argument

Description

filenumber

The number assigned in the Open statement to the file to be queried

position

An expression of type long representing the starting position of the next


record number for a random read or write operation, or the byte offset
from the beginning of the file

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Seek Statement

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

Siebel VB Language Reference

3-287

Siebel VB Language Reference


Select Case Statement

Select Case Statement

This standard VB control structure executes one or more statements, depending on


the value of an expression.
Syntax

Select Case testexpression


Case expressionList
[statement_block]
[Case expressionList
[statement_block] ]
.
.
[Case Else
[statement_block]
End Select
Placeholder

Description

testexpression

Any expression containing a variable to test

expressionList

One or more expressions that contain a possible value for


testexpression

statement_block

One or more lines of code to execute if testexpression equals a value


in expressionList

Returns

Not applicable

3-288

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Select Case Statement

Usage

When there is a match between testexpression and one of the values in


expressionList, the statement_block following the Case clause is executed. When the
next Case clause is reached, execution control goes to the statement following the
End Select statement.
The expressionList(s) can be a comma-separated list of expressions of the following
forms:
expression
expression To expression
Is comparison_operator expression
The type of each expression must be compatible with the type of testexpression.
Each statement_block can contain any number of statements on any number of
lines.
NOTE: When the To keyword is used to specify a range of values, the smaller value
must appear first. The comparison_operator used with the Is keyword is one of the
following: <, >, = , < = , > = , <> . You must also use the Is operator when
the Case is one end of a range, for example, Case Is < 100.

Version 6.0

Siebel VB Language Reference

3-289

Siebel VB Language Reference


Select Case Statement

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

If...Then...Else Statement on page 3-154, On...GoTo Statement on page 3-234, and


Option Compare Statement on page 3-244

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SendKeys Statement

SendKeys Statement

This standard VB statement sends keystrokes to an active Windows application.


Syntax

SendKeys string[, wait]


Argument

Description

string

A string or string expression containing the characters to send

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

The keystrokes are represented by characters of string.


The default value for wait is 0 (FALSE).
To specify an alphanumeric character, enter it in string. For example, to send the
character a, use a as string. Several characters can be combined in one string: If
string is abc, then a, b, and c will be sent to the application.
To specify that the Shift, Alt, or Control key should be pressed simultaneously with
a character, prefix the character with
+

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

Siebel VB Language Reference

3-291

Siebel VB Language Reference


SendKeys Statement

The following characters must be enclosed in braces if they are to be understood as


literal characters by SendKeys; otherwise they have specific meanings as follows:
+

SHIFT key

ALT key

CTRL key

()

Apply a shift state to the enclosed characters

Newline, or Enter key on the standard keyboard

{}

Used to make the enclosed characters literals

[]

No special meaning for SendKeys, but may have


special meaning in other applications

For example, a string equal to {%} specifies a literal percent character, %.


Use {{} to send a left brace and {}} to send a right brace.
To send the same key several times, enclose the character in braces and specify the
number of keys sent after a space: For example, use {X 20} to send 20 X
characters.
To send one of the non-printable keys, use a special keyword inside braces:

3-292

Key

Keyword

Backspace

{BACKSPACE} or {BKSP} or {BS}

Break

{BREAK}

Caps Lock

{CAPSLOCK}

Clear

{CLEAR}

Delete

{DELETE} or {DEL}

Down Arrow

{DOWN}

End

{END}

Enter (on keypad)

{ENTER}

Esc

{ESCAPE} or {ESC}

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SendKeys Statement

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

Siebel VB Language Reference

3-293

Siebel VB Language Reference


Service_InvokeMethod Event

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

The InvokeMethod event is called after the InvokeMethod method is called on a


business service. For details, see the Siebel Object Interfaces Reference.

Service_PreInvokeMethod Event

The PreInvokeMethod event is called before a specialized method is invoked on the


business service. For details, see the Siebel Object Interfaces Reference.

3-294

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Set Statement

Set Statement

This standard VB statement assigns a COM object, such as an application, to a


variable. Within Siebel Tools, it is used to create an instance of a Siebel object.
Syntax

Set variableName = objectExpression


Argument

Description

variableName

An object variable or variant variable

objectExpression

An expression that evaluates to an objecttypically a function, an


object member, or Nothing

Returns

Not applicable

Usage

The following example shows how to use the Set statement:


Dim COMObject As Object
Set COMObject = CreateObject("spoly.cpoly")
COMObject.reset
NOTE: If you omit the keyword Set when assigning an object variable, Siebel VB will
try to copy the default member of one object to the default member of another. This
usually results in a runtime error:

' Incorrect code - tries to copy default member!


COMObject = GetObject("","spoly.cpoly")

Set differs from Let in that Let assigns an expression to a Siebel VB variable. For
example,

Version 6.0

Set o1 = o2

sets the object reference

Let o1 = o2

sets the value of the default member

Siebel VB Language Reference

3-295

Siebel VB Language Reference


Set Statement

Example

This example creates an Opportunity Siebel business component outside the


context of the user interface. The program prevents the user from deleting an
account if there are opportunities associated with it. For details on the Siebel VB
methods and objects used in this example, see the Siebel Object Interfaces Reference.
Function BusComp_PreDeleteRecord As Integer
Dim iReturn as integer
Dim oBC as BusComp
Dim oBO as BusObject
Dim sAcctRowId as string
iReturn = ContinueOperation
sAcctRowId = me.GetFieldValue("Id")
set oBO = theApplication.GetBusObject("Opportunity")
set oBC = oBO.GetBusComp("Opportunity")
With oBC
.SetViewMode AllView
.ActivateField "Account Id"
.ClearToQuery
.SetSearchSpec "Account Id", sAcctRowId
.ExecuteQuery ForwardOnly
if (.FirstRecord) = 1 then
MsgBox("Opportunities exist for the Account - Delete is
not allowed")
iReturn = CancelOperation
end if
End With
BusComp_PreDeleteRecord = iReturn
Set oBC = Nothing
Set oBO = Nothing
End Function

See Also

3-296

CreateObject Function on page 3-50, Is Operator on page 3-173, Me on page 3-206,


New Operator on page 3-222, Nothing Function on page 3-224, Object Class on
page 3-231, and Typeof Function on page 3-356

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SetAttr Statement

SetAttr Statement

This standard VB statement sets the file attributes for a specified file.
Syntax

SetAttr pathname, attributes


Argument

Description

pathname

A string or string expression evaluating to the name of the file to modify

attributes

An integer expression containing the new attributes for the file

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

Archivefile has changed since last backup

Example

For an example, see the Select Case Statement on page 3-288.

See Also

FileAttr Function on page 3-101 and GetAttr Function on page 3-135

Version 6.0

Siebel VB Language Reference

3-297

Siebel VB Language Reference


SetFieldValue Method

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

SetNamedSearch sets a named search specification on a Siebel business


component. A named search specification is identified by the searchName
argument. This method is used with business component objects. For details, see
the Siebel Object Interfaces Reference.

SetProfileAttr Method

SetProfileAttr is used in personalization to assign values to attributes in a user


profile. For details, see the Siebel Object Interfaces Reference.

SetProperty Method

This method assigns a value to a property of a business service, property set, or


control. For details, see the Siebel Object Interfaces Reference.

3-298

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SetSearchExpr Method

SetSearchExpr Method

SetSearchExpr sets an entire search expression on a Siebel business component,


rather than setting one search specification per field. Syntax is similar to that on the
Predefined Queries screen. This method is used with business component objects.
For details, see the Siebel Object Interfaces Reference.

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

The SetSharedGlobal property sets a shared user-defined global variable, which


may be accessed using GetSharedGlobal. This method is used with the application
object. For details, see the Siebel Object Interfaces Reference.

SetSortSpec Method

SetSortSpec sets the sorting specification for a query on a Siebel business


component. This method is used with business component objects. For details, see
the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

3-299

Siebel VB Language Reference


SetUserProperty Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Sgn Function

Sgn Function

This standard VB function returns a value indicating the sign of a number.


Syntax

Returns

Sgn(number)
Argument

Description

number

A numeric expression for which the sign is to be determined

If number is less than zero, -1.


If number is equal to zero, 0.
If number is greater than zero, 1.

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

Siebel VB Language Reference

3-301

Siebel VB Language Reference


Shell Function

Shell Function

This standard VB function starts a Windows application and returns its task ID.
Syntax

Shell(pathname, [windowStyle])
Argument

Description

pathname

A string or string expression evaluating to the name of the program to


execute

windowStyle

An integer indicating how the programs window is to be displayed:

 1 if a normal window with focus


 2 if a minimized window with focus
 3 if a maximized window with focus
 4 if a normal window without focus
 7 if a minimized window without focus

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

AppActivate Statement on page 3-19 and SendKeys Statement on page 3-291

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


ShowStatus Method

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

Siebel VB Language Reference

3-303

Siebel VB Language Reference


Sin Function

Sin Function

This standard VB function returns the sine of an angle specified in radians.


Syntax

Sin(number)
Argument

Description

number

A numeric expression containing a number representing the size of an


angle in radians

Returns

The sine of number.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Space Function

Space Function

This standard VB function returns a string of spaces.


Syntax

Space[$](number)
Argument

Description

number

A numeric expression indicating the number of spaces to return

Returns

A string of number spaces.

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

For an example, see the Oct Function on page 3-233.

See Also

Spc Function on page 3-306 and String Function on page 3-334

Version 6.0

Siebel VB Language Reference

3-305

Siebel VB Language Reference


Spc Function

Spc Function

This standard VB function prints a specified number of spaces.


Syntax

Spc(number)
Argument

Description

number

An integer or integer expression indicating the number of spaces to print

Returns

A string of spaces in the target of a Print statement.

Usage

The Spc function can be used only inside a Print statement.


When the Print statement is used, the Spc function will use the following rules for
determining the number of spaces to output:

 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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Spc Function

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

Siebel VB Language Reference

3-307

Siebel VB Language Reference


SQLClose Function

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

A named argument that must be a long integer, returned by SQLOpen

A variant having one of the following values:


Value

Meaning

Successful disconnection

-1

Connection is not valid

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLClose Function

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

Version 6.0

SQLError Function on page 3-310, SQLExecQuery Function on page 3-312,


SQLGetSchema Function on page 3-314, SQLOpen Function on page 3-317,
SQLRequest Function on page 3-320, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

3-309

Siebel VB Language Reference


SQLError Function

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

A two-dimensional array of type variant, in which each row contains


one error

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:

A character string indicating the ODBC error class/subclass

Element 2:

A numeric value indicating the data source native error code

Element 3:

A text message describing the error

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLError Function

Example

This example forces an error to test the SQLError function.


Sub Button_Click
' Declarations
Dim connection As long
Dim prompt as integer
Dim retcode as long
Dim errors(1 To 10, 1 To 3) as Variant
' Open the data source
connection = SQLOpen("DSN = SVBTESTW;UID = DBA;PWD =
SQL",outputStr, prompt: = 3)
' force an error to test SQLError select a nonexistent table
retcode = SQLExecQuery(connection: = connection, query: =
"select * from notable ")
' Retrieve the detailed error message information into the
' errors array
SQLError destination: = errors
errCounter = 1
while errors(errCounter,1) <>0
msgbox
"ODBC error class = " & errors(errCounter,1) &
chr$(10) & "Numeric code = " & errors(errCounter,2) & chr$(10) &
"Text = " & errors(errCounter,3)
errCounter = errCounter + 1
wend
retcode = SQLClose(connection)
end sub

See Also

Version 6.0

SQLClose Function on page 3-308, SQLExecQuery Function on page 3-312,


SQLGetSchema Function on page 3-314, SQLOpen Function on page 3-317,
SQLRequest Function on page 3-320, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

3-311

Siebel VB Language Reference


SQLExecQuery Function

SQLExecQuery Function

This custom VB function executes an SQL statement on a connection established by


SQLOpen.
Syntax

Returns

Usage

SQLExecQuery(connection, query)
Argument

Description

connection

A long integer returned by SQLOpen

query

A string containing a valid SQL statement

The number of columns in the result set for SQL SELECT statements as a variant.
Select Statement

Return Value

UPDATE

The number of rows affected by the statement

INSERT

The number of rows affected by the statement

DELETE

The number of rows affected by the statement

All other SQL


statements

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLExecQuery Function

Example

This example performs a query on the data source.


Sub Button_Click
' Declarations
Dim connection As Long
Dim destination(1 To 50, 1 To 125)
Dim retcode As long

As Variant

' open the connection


connection = SQLOpen("DSN = SblTest",outputStr,prompt: = 3)
' Execute the query
query = "select * from customer"
retcode = SQLExecQuery(connection,query)
' retrieve the first 50 rows with the first 6 columns of
' each row into the array destination, omit row numbers and
' put column names in the first row of the array
retcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1,rowNumbers: _
= 0,maxRows: = 50, maxColumns: = 6,fetchFirst: = 0)
' Get the next 50 rows of from the result set
retcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1,rowNumbers: _
= 0,maxRows: = 50, maxColumns: = 6)
' Close the connection
retcode = SQLClose(connection)
End Sub

See Also

Version 6.0

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLGetSchema Function on page 3-314, SQLOpen Function on page 3-317,
SQLRequest Function on page 3-320, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

3-313

Siebel VB Language Reference


SQLGetSchema Function

SQLGetSchema Function

This custom VB function returns a variety of information, including information on


the data sources available, current user ID, names of tables, names and types of
table columns, and other data source/database related information.
Syntax

Returns

SQLGetSchema connection, action, qualifier, ref()


Argument

Description

connection

A long integer returned by SQLOpen

action

An integer value from the following table, specifying what is to be returned


to ref()

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

A variant whose value depends on the action requested, as determined by the


values in the following table. A negative return value indicates an error. A -1 is
returned if the requested information cannot be found or if the connection is not
valid.
Table 3-1.

3-314

Values for Action

(Sheet 1 of 2)

Action
Value

Returns

List of available data sources (dimension of ref() is 1)

List of databases on the current connection (not supported)

List of owners in a database on the current connection (not supported)

List of tables on the specified connection

List of columns in a the table specified by qualifier (ref() must be two


dimensions); returns column name and SQL data type

The user ID of the current connection user

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLGetSchema Function

Table 3-1.

Usage

Values for Action

(Sheet 2 of 2)

Action
Value

Returns

The name of the current database

The name of the data source for the current connection

The name of the DBMS the data source uses (for example, DB2)

10

The server name for the data source

11

The terminology used by the data source to refer to owners

12

The terminology used by the data source to refer to a table

13

The terminology used by the data source to refer to a qualifier

14

The terminology used by the data source to refer to a procedure

The destination array must be properly dimensioned to support the action, or an


error will be returned. Actions 2 and 3 are not currently supported. Action 4 returns
all tables and does not support the use of the qualifier. Not all database products
and ODBC drivers support all actions.
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.

Version 6.0

Siebel VB Language Reference

3-315

Siebel VB Language Reference


SQLGetSchema Function

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

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLExecQuery Function on page 3-312, SQLOpen Function on page 3-317,
SQLRequest Function on page 3-320, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLOpen Function

SQLOpen Function

This custom VB function establishes a connection to an ODBC data source.


Syntax

SQLOpen(connectString, [outputString][, prompt])


Argument

Description

connectString

A string or string variable supplying all the information required to


connect to a data source, including the data source name, user ID, and
password, and any other information required by the driver to make
the connection

outputString

A string variable to hold the completed connection string if the


connection is successful

prompt

An integer specifying when the driver dialog box is displayed

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 always displayed

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.

Siebel VB Language Reference

3-317

Siebel VB Language Reference


SQLOpen Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLOpen Function

See Also

Version 6.0

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLExecQuery Function on page 3-312, SQLGetSchema Function on page 3-314,
SQLRequest Function on page 3-320, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

3-319

Siebel VB Language Reference


SQLRequest Function

SQLRequest Function

This custom VB function establishes a connection to a data source, executes an SQL


statement contained in query$, returns the results of the request in the ref() array,
and closes the connection.
Syntax

SQLRequest(connectString, query, outputString[, prompt][, columnNames], ref())


Argument

Description

connectString

A string or string variable specifying the data source to connect to1

query

An SQL query

outputString

A string variable to hold the completed connection string if the


connection is successful

prompt

An integer that specifies when driver dialog boxes are displayed2

columnNames

An integer with a value of 0 or nonzero. When columnNames is


nonzero, column names are returned as the first row of the ref() array.
If columnNames is omitted, the default is 0.

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

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

A variant containing a negative-numbered error code if the connection cannot be


made, the query is invalid, or another error condition occurs. If the request is
successful, returns a positive number representing the number of results returned
or rows affected. Other SQL statements return 0.

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLRequest Function

Usage

The SQLRequest function establishes a connection to the data source specified in


connectString, executes the SQL statement contained in query, returns the results of
the request in the ref() array, and closes the connection.
The arguments must be named arguments. 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.

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

' The following will open the datasource SVBTESTW and


' execute the query specified by query and return the
' results in destination
query = "select * from class"
retcode = SQLRequest("DSN = SVBTESTW;UID = DBA;PWD = SQL", _
query, outputStr, prompt, 0, destination())
End Sub

See Also

Version 6.0

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLExecQuery Function on page 3-312, SQLGetSchema Function on page 3-314,
SQLOpen Function on page 3-317, SQLRetrieve Function on page 3-322, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

3-321

Siebel VB Language Reference


SQLRetrieve Function

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

SQLRetrieve(connection, destination()[, maxColumns][, maxRows]


[, columnNames][, rowNumbers][, fetchFirst])
Argument

Description

connection

The long integer returned by the SQLOpen function

destination()

A two-dimensional array of type variant

maxColumns

The number of columns to be retrieved in the request; defaults to 0 if


this parameter is not used

maxRows

The number of rows to be retrieved in the request; if this argument is


not supplied, a zero is assumed

columnNames

An integer with a value of 0 or nonzero. When columnNames is


nonzero, column names are returned as the first row of the ref() array.
If columnNames is omitted, the default is 0.

rowNumbers

An integer with a value of 0 or nonzero. When rowNumbers is


nonzero, row numbers are returned as the first row of the ref() array.
If rowNumbers is omitted, the default is 0.

fetchFirst

A positive integer value that causes the result set to be repositioned to


the first row of the database, if the database supports this action;
returns -1 if this cannot be accomplished

A variant containing the following values:


Result

Returns

Success

The number of rows in the result set or the maxRows


requested

Unable to retrieve results, or no


results pending

-1

No data found by the query

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLRetrieve Function

Usage

If maxColumns or maxRows is omitted, the array size is used to determine the


maximum number of columns and rows retrieved, and an attempt is made to return
the entire result set. Extra rows can be retrieved by using SQLRetrieve again and by
setting fetchFirst to 0. If maxColumns specifies fewer columns than are available in
the result, SQLRetrieve discards the rightmost result columns until the results fit the
specified size.
When columnNames is nonzero, the first row of the array will be set to the column
names as they are specified by the database schema. When rowNumbers is nonzero,
row numbers are returned in the first column of destination(). SQLRetrieve will
clear the users array prior to fetching the results.
When fetchFirst is nonzero, it causes the result set to be repositioned to the first row
if the database supports the function. If the database does not support
repositioning, the result set -1 error will be returned.
If there are more rows in the result set than can be contained in the destination()
array or than have been requested using maxRows, the user can make repeated calls
to SQLRetrieve until the return value is 0.
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.

Version 6.0

Siebel VB Language Reference

3-323

Siebel VB Language Reference


SQLRetrieve Function

Example

This example retrieves information from a data source.


Sub Button_Click
' Declarations
Dim connection As Long
Dim destination(1 To 50, 1 To 125)
Dim retcode As long

As Variant

' open the connection


connection = SQLOpen("DSN = SblTest",outputStr,prompt: = 3)
' Execute the query
query = "select * from customer"
retcode = SQLExecQuery(connection,query)
' retrieve the first 50 rows with the first 6 columns of
' each row into the array destination, omit row numbers and
' put column names in the first row of the array
retcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1,rowNumbers: = 0, _
maxRows: = 50, maxColumns: = 6,fetchFirst: = 0)
' Get the next 50 rows of from the result set
retcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1,rowNumbers: = 0, _
maxRows: = 50, maxColumns: = 6)
' Close the connection
retcode = SQLClose(connection)
End Sub

See Also

3-324

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLExecQuery Function on page 3-312, SQLGetSchema Function on page 3-314,
SQLOpen Function on page 3-317, SQLRequest Function on page 3-320, and
SQLRetrieveToFile Function on page 3-325

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


SQLRetrieveToFile Function

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

SQLRetrieveToFile(connection, destination[, columnNames][, columnDelimiter])


Argument

Description

connection

The number returned by the SQLOpen function

destination

A string or string variable containing the filename and path to be used


for storing the results

columnNames

One of the following values:

 nonzero = The first row contains the column headers as specified


by the database schema

 0 = The column headers are not retrieved


The default is 0.
columnDelimiter

The string to be used to delimit the fields in a row; if omitted, a Tab


character is used

Returns

If successful, a variant containing the number of rows in the result set; if


unsuccessful, -1.

Usage

The arguments must be named arguments. 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.

Version 6.0

Siebel VB Language Reference

3-325

Siebel VB Language Reference


SQLRetrieveToFile Function

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

'open the connection


connection = SQLOpen("DSN = SblTest",outputStr,prompt: = 3)
' Execute the query
query = "select * from customer"
retcode = SQLExecQuery(connection,query)
'Place the results of the previous query in the file
'named by filename and put the column names in the file
'as the first row.
'The field delimiter is %
filename = "c:\myfile.txt"
columnDelimiter = "%"
retcode = SQLRetrieveToFile(connection: = connection, _
destination: = filename, columnNames: = 1, _
columnDelimiter: = columnDelimiter)
retcode = SQLClose(connection)
End Sub

See Also

3-326

SQLClose Function on page 3-308, SQLError Function on page 3-310,


SQLExecQuery Function on page 3-312, SQLGetSchema Function on page 3-314,
SQLOpen Function on page 3-317, SQLRequest Function on page 3-320, and
SQLRetrieve Function on page 3-322

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Sqr Function

Sqr Function

This standard VB function returns the square root of a number.


Syntax

Sqr(number)
Argument

Description

number

An expression containing the number whose square root is to be found

Returns

The square root of number.

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

For an example that calculates the square root of 2 as a double-precision floating


point value and displays it in scientific notation, see the Format Function on
page 3-114.

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

Siebel VB Language Reference

3-327

Siebel VB Language Reference


Static Statement

Static Statement

This standard VB statement declares variables and allocates storage space.


Syntax

Static variableName [As type] [,variableName [As type]] ...


Argument

Description

variableName

The name of the variable to declare as static

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Static Statement

If Err <> 0 then


MsgBox "Error occurred. Try again."
Err = 0
Goto i
End If
If grecord.acctno <> 0 then
Print #1, grecord.acctno
x = x + 1
End If
Loop
Close #1
total = x-1
msgtext = "The account numbers are: " & Chr(10)
Open "c:\temp001" For Input as #1
For x = 1 to total
Input #1, grecord.acctno
msgtext = msgtext & Chr(10) & grecord.acctno
Next x
MsgBox msgtext
Close #1
Kill "c:\temp001"
End Sub

See Also

Version 6.0

Dim Statement on page 3-73, Function...End Function Statement on page 3-127,


Global Statement on page 3-144, Option Base Statement on page 3-241, ReDim
Statement on page 3-263, and Sub...End Sub Statement on page 3-336

Siebel VB Language Reference

3-329

Siebel VB Language Reference


Stop Statement

Stop Statement

This standard VB statement halts program execution.


Syntax

Stop
Argument

Description

Not applicable

Returns

Not applicable

Usage

Stop statements can be placed anywhere in a program to suspend its execution.


Although the Stop statement halts program execution, it does not close files or clear
variables.

Example

This example stops program execution at the users request.


Sub Button_Click
Dim str1
str1 = InputBox("Stop program execution? (Y/N):")
If str1 = "Y" or str1 = "y" then
Stop
End If
MsgBox "Program complete."
End Sub

3-330

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Str Function

Str Function

This standard VB function returns a string representation of a number.


Syntax

Str[$](number)
Argument

Description

number

The number to be represented as a string

Returns

A string representation of number.

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

Format Function on page 3-114 and Val Function on page 3-362

Siebel VB Language Reference

3-331

Siebel VB Language Reference


StrComp Function

StrComp Function

This standard VB function compares two strings and returns an integer specifying
the result of the comparison.
Syntax

StrComp(string1, string2[, compare])


Argument

Description

string1

An expression containing the first string to compare

string2

An expression containing the second string to compare

compare

An integer indicating the method of comparison, where:


0 = case-sensitive
1 = case-insensitive

Returns

Usage

One of the following values:


Value

Meaning

-1

string1 < string2

string1 = string2

>1

string1 > string2

Null

string1 = Null or string2 = Null

If compare is 0, a case sensitive comparison based on the ANSI character set


sequence is performed. If compare is 1, a case insensitive comparison is done based
upon the relative order of characters as determined by the country code setting for
your system. If this argument is omitted, the module-level default, as specified with
Option Compare, is used.
The string1 and string2 arguments are both passed as variants. Therefore, any type
of expression is supported. Numbers will be automatically converted to strings.

3-332

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


StrComp Function

Example

This example compares a user-entered string to the string Smith.


Option Compare Text
Sub Button_Click
Dim lastname as String
Dim smith as String
Dim x as Integer
smith = "Smith"
lastname = InputBox("Type your last name")
x = StrComp(lastname,smith,1)
If x = 0 then
MsgBox "You typed 'Smith' or 'smith'."
Else
MsgBox "You typed: " & lastname & " not 'Smith'."
End If
End Sub

See Also

Version 6.0

InStr Function on page 3-163 and Option Compare Statement on page 3-244

Siebel VB Language Reference

3-333

Siebel VB Language Reference


String Function

String Function

This standard VB function returns a string consisting of a repeated character.


Syntax A

String[$](number, character)

Syntax B

String[$] (number, stringExpression)


Argument

Description

number

The length of the string to be returned

character

An integer or integer expression containing the ANSI code of the


character to use

stringExpression

A string argument, the first character of which becomes the


repeated character

Returns

A string containing number repetitions of the specified character.

Usage

Number must be between 0 and 32,767.


Character must evaluate to an integer between 0 and 255.
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-334

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


String Function

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

Space Function on page 3-305 and Str Function on page 3-331

Siebel VB Language Reference

3-335

Siebel VB Language Reference


Sub...End Sub Statement

Sub...End Sub Statement

This standard VB construct defines a subprogram procedure.


Syntax

[Static] [Private] Sub name [([Optional] parameter [ As type] , ...)]


End Sub
Argument

Description

name

The name of the subprogram

parameter

A list of parameter names, separated by commas

type

The data type for parameter

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Sub...End Sub Statement

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

This example is a subroutine that uses the Sub...End Sub statement.


Sub Button1_Click
MsgBox "Hello, World."
End Sub

See Also

Version 6.0

BusComp Method on page 3-25, Dim Statement on page 3-73, Function...End


Function Statement on page 3-127, Global Statement on page 3-144, Option Explicit
Statement on page 3-246, and Static Statement on page 3-328

Siebel VB Language Reference

3-337

Siebel VB Language Reference


SuppressNotification Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Tab Function

Tab Function

This standard VB function moves the current print position to the column specified.
Syntax

Tab(position)
Argument

Description

position

The position at which printing is to occur

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

Siebel VB Language Reference

3-339

Siebel VB Language Reference


Tab Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Tan Function

Tan Function

This standard VB function returns the tangent of an angle in radians.


Syntax

Tan(number
Argument

Description

number

A numeric expression containing the number of radians in the angle


whose tangent is to be returned

Returns

The tangent of number.

Usage

Number is specified in radians and can be either positive or negative.


The return value is single precision if the angle is an integer, currency, or singleprecision value; double precision for a long, variant, or double-precision value.
To convert degrees to radians, multiply by PI/180. The value of PI is 3.14159.

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

Siebel VB Language Reference

3-341

Siebel VB Language Reference


theApplication Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Time Function

Time Function

This standard VB function returns a string representing the current time.


Syntax

Time[$]
Argument

Description

Not applicable

Returns

An eight-character string of the format hh:mm:ss, where hh is the hour, mm is the


minutes, and ss is the seconds. The hour is specified in military style and ranges
from 0 to 23.

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

Siebel VB Language Reference

3-343

Siebel VB Language Reference


Time Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Time Statement

Time Statement

This standard VB statement sets the system time.


Syntax

Time[$] = expression
Placeholder

Meaning

expression

An expression that evaluates to a valid time

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

Sets the time to hh hours 0 minutes and 0 seconds.

hh:mm

Sets the time to hh hours mm minutes and 0 seconds.

hh:mm:ss Sets the time to hh hours mm minutes and ss seconds.


Time uses a 24-hour clock. Thus, 6:00 P.M. must be entered as 18:00:00.
If the dollar sign ($) is omitted, expression can be a string containing a valid date,
a variant of vartype 7 (date), or 8 (string).
If expression is not already a variant of vartype 7 (date), Time attempts to convert
it to a valid time. It recognizes time separator characters defined in the International
section of the Windows Control Panel. Time (without the $) accepts both 12 and 24
hour clocks.

Version 6.0

Siebel VB Language Reference

3-345

Siebel VB Language Reference


Time Statement

Example

This example changes the time on the system clock.


Sub Button_Click
Dim newtime As String
Dim answer As String
On Error Resume Next
i:
newtime = InputBox("What time is it?")
answer = InputBox("Is this AM or PM?")
If answer = "PM" or answer = "pm" then
newtime = newtime &"PM"
End If
Time = newtime
If Err <> 0 then
MsgBox "Invalid time. Try again."
Err = 0
Goto i
End If
End Sub

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Timer Function

Timer Function

This standard VB function returns the number of seconds that have elapsed since
midnight.
Syntax

Timer
Argument

Description

Not applicable

Returns

The number of seconds that have elapsed since midnight.

Usage

The Timer function can be used in conjunction with the Randomize statement to
seed the random number generator.

Example

This example uses the Timer to find Megabucks numbers.


Sub Button_Click
Dim msgtext As String
Dim value(9) As Single
Dim nextvalue As Integer
Dim x As Integer
Dim y As Integer
msgtext = "Your Megabucks numbers are: "
For x = 1 to 8
Do
value(x) = Timer
value(x) = value(x) * 100
value(x) = Str(value(x))
value(x) = Val(Right(value(x),2))
Loop Until value(x)>1 and value(x)<36
For y = 1 to 1500
Next y
Next x

Version 6.0

Siebel VB Language Reference

3-347

Siebel VB Language Reference


Timer Function

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

Randomize Statement on page 3-260

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


TimeSerial Function

TimeSerial Function

This standard VB function returns a time as a variant of type 7 (date/time) for a


specific hour, minute, and second.
Syntax

TimeSerial(hour, minute, second)


Argument

Description

hour

A numeric expression containing a value from 0 to 23 representing an hour

minute

A numeric expression containing a value from 0 to 59 representing a minute

second

A numeric expression containing a value from 0 to 59 representing a second

Returns

A time as a specific hour, minute, and second.

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

This example displays the current time using TimeSerial.


Sub Button_Click
Dim y As Variant
Dim msgtext As String
Dim nowhr As Integer
Dim nowmin As Integer
Dim nowsec As Integer
nowhr = Hour(Now)
nowmin = Minute(Now)
nowsec = Second(Now)
y = TimeSerial(nowhr,nowmin,nowsec)
msgtext = "The time is: " & y
MsgBox msgtext
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 TimeValue Function on page 3-350

Siebel VB Language Reference

3-349

Siebel VB Language Reference


TimeValue Function

TimeValue Function

This standard VB function returns a time value for a specified string.


Syntax

TimeValue(time)
Argument

Description

time

A string representing a valid date-time value

Returns

A date/time value for the time represented by time.

Usage

The TimeValue function returns a variant of vartype 7 (date/time) that represents a


time between 0:00:00 and 23:59:59, or 12:00:00 A.M. and 11:59:59 P.M., inclusive.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


TimeValue Function

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

Siebel VB Language Reference

3-351

Siebel VB Language Reference


Trace Method

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Trim Function

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

A literal or expression from which leading and trailing spaces are to be


removed

Returns

A copy of string with leading and trailing spaces removed.

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

Siebel VB Language Reference

3-353

Siebel VB Language Reference


Type Statement

Type Statement

This standard VB statement declares a user-defined type.


Syntax

Type userType
field1 As type1
field2 As type2
...
End Type
Argument

Description

userType

The name of the user-defined type

field1, field2

The names of fields in the user-defined type

type1, type2

The data types of the respective fields

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Type Statement

No memory is allocated when a type is defined. Memory is allocated when a


variable of the user-defined type is declared with a Dim statement. Declaring a
variable of a user-defined type is called instantiating, or declaring an instance of,
the type.
Example

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

Deftype Statement on page 3-71 and Dim Statement on page 3-73

Siebel VB Language Reference

3-355

Siebel VB Language Reference


Typeof Function

Typeof Function

This standard VB function returns a value indicating whether an object is of a given


class.
Syntax

If Typeof objectVariable Is className Then...


Placeholder

Meaning

objectVariable

The object to be tested

className

The class to which the object is to be compared

Returns

-1 if the object is of the specified type, 0 if it is not.

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

CreateObject Function on page 3-50, GetObject Function on page 3-139, Is Operator


on page 3-173, Me on page 3-206, New Operator on page 3-222, Nothing Function
on page 3-224, and Object Class on page 3-231

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


UBound Function

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

The variable name of the array to be tested

dimension

The array dimension whose upper bound is to be returned

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

Siebel VB Language Reference

3-357

Siebel VB Language Reference


UBound Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


UCase Function

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

A string or string expression

Returns

A copy of string with all lowercase letters replaced by uppercase letters.

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

This example converts a filename entered by a user to all uppercase letters.


Option Base 1
Sub Button_Click
Dim filename as String
filename = InputBox("Enter a filename: ")
filename = UCase(filename)
MsgBox "The filename in uppercase is: " & filename
End Sub

See Also

Version 6.0

Asc Function on page 3-22 and LCase Function on page 3-187

Siebel VB Language Reference

3-359

Siebel VB Language Reference


UndoRecord Method

UndoRecord Method

UndoRecord deletes an active record created by NewRecord in a Siebel business


component. This method is used with business component objects. For details, see
the Siebel Object Interfaces Reference.

3-360

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Unlock Statement

Unlock Statement

This standard VB statement controls access to an open file.


Syntax

Unlock [#]filenumber[, { record | [start] To end } ]


Argument

Description

filenumber

The file number used in the Open statement to open the file

record

An integer indicating the first record to unlock

start

A long integer indicating the first record or byte offset to unlock

end

A long integer indicating the last record or byte offset to 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

For an example of the Unlock statement, see the Lock Statement on page 3-198.

See Also

Lock Statement on page 3-198 and Open Statement on page 3-238

Version 6.0

Siebel VB Language Reference

3-361

Siebel VB Language Reference


Val Function

Val Function

This standard VB function returns the numeric value of the first number found in a
string.
Syntax

Val(string)
Argument

Description

string

A string or string expression containing a number

Returns

The value of the first number in string. If no number is found, Val returns 0.

Usage

Spaces in the source string are ignored.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


VarType Function

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

The name of the variant variable to query

The value returned by VarType is one of the following:


Ordinal

Representation

(Empty)

Null

Integer

Long

Single

Double

Currency

Date

String

Object

Siebel VB Language Reference

3-363

Siebel VB Language Reference


VarType Function

Example

This example returns the type of a variant.


Sub Button_Click
Dim x
Dim myarray(8)
Dim retval
Dim retstr
myarray(1) = Null
myarray(2) = 0
myarray(3) = 39000
myarray(4) = CSng(10^20)
myarray(5) = 10^300
myarray(6) = CCur(10.25)
myarray(7) = Now
myarray(8) = "Five"
For x = 0 to 8
retval = Vartype(myarray(x))
Select Case retval
Case 0
retstr = " (Empty)"
Case 1
retstr = " (Null)"
Case 2
retstr = " (Integer)"
Case 3
retstr = " (Long)"
Case 4
retstr = " (Single)"
Case 5
retstr = " (Double)"
Case 6
retstr = " (Currency)"
Case 7
retstr = " (Date)"
Case 8
retstr = " (String)"
End Select
If retval = 1 then
myarray(x) = "[null]"
ElseIf retval = 0 then
myarray(x) = "[empty]"
End If
MsgBox "The variant type for " &myarray(x) & " is: " _
&retval &retstr
Next x
End Sub

3-364

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


VarType Function

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

Siebel VB Language Reference

3-365

Siebel VB Language Reference


WebApplet_InvokeMethod Event

WebApplet_InvokeMethod Event

The InvokeMethod event is triggered by a call to WebApplet.InvokeMethod or a


specialized method, or by a user-defined menu. For details, see the Siebel Object
Interfaces Reference.

WebApplet_PreInvokeMethod Event

The PreInvokeMethod event is called before a specialized method is invoked by the


system, by a user-defined applet menu, or by calling InvokeMethod on a web
applet. For details, see the Siebel Object Interfaces Reference.

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Weekday Function

Weekday Function

This standard VB function returns the day of the week for a specified date-time
value.
Syntax

Weekday(date)
Argument

Description

date

An expression containing a date/time value

Returns

An integer between 1 and 7, inclusive, representing a day of the week, where 1 =


Sunday and 7 = Saturday.

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

Siebel VB Language Reference

3-367

Siebel VB Language Reference


Weekday Function

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


While...Wend Statement

While...Wend Statement

This standard VB control structure controls a repetitive action.


Syntax

While condition
statement_block
Wend
Placeholder

Meaning

condition

A condition under which to execute the statements in


statement_block

statement_block

A series of statements to execute while condition is TRUE

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

Siebel VB Language Reference

3-369

Siebel VB Language Reference


While...Wend Statement

Write #1, ontime


Next x
Close #1
Open "c:\temp002" for Output as #1
Write #1, odue
Close #1
End Sub
Sub Button_Click
Dim custfile as String
Dim aline as String
Dim pattern as String
Dim count as Integer
Call CreateFiles
Chdir "c:\"
custfile = Dir$("temP00?")
pattern = "*" + "Overdue" + "*"
While custfile <> ""
Open custfile for input as #1
On Error goto atEOF
Do
Line Input #1, aline
If aline Like pattern Then
count = count + 1
End If
Loop
nxtfile:
On Error GoTo 0
Close #1
custfile = Dir$
Wend
If count <> 0 then
Msgbox "Number of overdue accounts: " & count
Else
Msgbox "No accounts overdue"
End If
Kill "c:\temp001"
Kill "c:\temp002"
Exit Sub
atEOF:
Resume nxtfile
End Sub

See Also

3-370

Do...Loop Statement on page 3-81

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


Width Statement

Width Statement

This standard VB statement sets the output line width for an open file.
Syntax

Width [#]filenumber, width


Argument

Description

filenumber

The file number used in the Open statement to open the file

width

An integer expression indicating the width of the output line

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

Open Statement on page 3-238 and Print Statement on page 3-254

Siebel VB Language Reference

3-371

Siebel VB Language Reference


With Statement

With Statement

This standard VB construct executes a series of statements on a specified variable.


Syntax

With variable
statement_block
End With
Placeholder

Meaning

variable

The variable to be changed by the statements in statement_block

statement_block

The statements to execute on the variable

Returns

Not applicable

Usage

Variable can be an object or a user-defined type. The With statements can be


nested.

3-372

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


With Statement

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

Type Statement on page 3-354

Siebel VB Language Reference

3-373

Siebel VB Language Reference


Write Statement

Write Statement

This standard VB statement writes data to an open sequential file.


Syntax

Write [#]filenumber[, expressionList]


Argument

Description

filenumber

The file number used in the Open statement to open the file

expressionList

One or more values to write to the file

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

Siebel VB Language Reference

Version 6.0

Siebel VB Language Reference


WriteRecord Method

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

Siebel VB Language Reference

3-375

Siebel VB Language Reference


Year Function

Year Function

This standard VB function returns the year component of a date-time value.


Syntax

Year(date)
Argument

Description

date

An expression that can evaluate to a date/time value

Returns

An integer between 100 and 9999, inclusive.

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

This example returns the year for today.


Sub Button_Click
Dim nowyear
nowyear = Year(Now)
MsgBox "The current year is: " &nowyear
End Sub

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

Siebel VB Language Reference

Version 6.0

How Siebel VB Compares to


Other Versions of Basic

Differences Between Siebel VB and Earlier Versions of Basic . . . . . . . . . .A-2


Line Numbers and Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
Subroutines and Modularity of the Language . . . . . . . . . . . . . . . . . . A-2
Variable Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A-3
Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Date and Time Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Object Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Environment Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Differences Between Siebel VB and Visual Basic . . . . . . . . . . . . . . . . . . A-5
User Interface and Control-Based Objects . . . . . . . . . . . . . . . . . . . . . A-5
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A-5

Version 6.0

Siebel VB Language Reference

A-1

How Siebel VB Compares to Other Versions of Basic


Differences Between Siebel VB and Earlier Versions of Basic

Differences Between Siebel VB and Earlier


Versions of Basic

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.

Line Numbers and Labels

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.

Subroutines and Modularity of the Language

Siebel VB is a modular language; code is divided into subroutines and functions.


The subprograms and functions you write use the Siebel VB statements and
functions to perform actions.

A-2

Siebel VB Language Reference

Version 6.0

How Siebel VB Compares to Other Versions of Basic


Differences Between Siebel VB and Earlier Versions of Basic

Variable Scope

The placement of variable declarations determines their scope:


Scope

Definition

Local

Dimensioned inside a subprogram or function. The variable is accessible only


to the subprogram or function that dimensioned it.

Module

Dimensioned in the (general) (declarations) section. The variable is accessible


to any subprogram, function, or event attached to the object in whose Script
window it appears.

Global

Dimensioned in the Application_Start event or Application.PreInvokeMethod


method. The variable is accessible throughout the Siebel application. See
Siebel Technical Note #217 for further information.

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.

Date and Time Functions

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

Siebel VB Language Reference

A-3

How Siebel VB Compares to Other Versions of Basic


Differences Between Siebel VB and Earlier Versions of Basic

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

Siebel VB Language Reference

Version 6.0

How Siebel VB Compares to Other Versions of Basic


Differences Between Siebel VB and Visual Basic

Differences Between Siebel VB and Visual Basic

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.

User Interface and Control-Based Objects

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

Siebel VB Language Reference

A-5

How Siebel VB Compares to Other Versions of Basic


Differences Between Siebel VB and Visual Basic

A-6

Siebel VB Language Reference

Version 6.0

Trappable Errors

About This Appendix

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

Error Numbers and Strings

(Sheet 1 of 3)

Error Text

Illegal function call

Overflow

Out of memory

Subscript out of range

10

Duplicate definition

11

Division by zero

13

Type Mismatch

14

Out of string space

19

No Resume

20

Resume without error

28

Out of stack space

35

Sub or Function not defined

48

Error in loading DLL

52

Bad file name or number

53

File not found

54

Bad file mode

Siebel VB Language Reference

B-1

Trappable Errors
About This Appendix

Table B-1.
Error code

B-2

Error Numbers and Strings

(Sheet 2 of 3)

Error Text

55

File already open

58

File already exists

61

Disk full

62

Input past end of file

63

Bad record number

64

Bad file name

68

Device unavailable

70

Permission denied

71

Disk not ready

74

Can't rename with different drive

75

Path/File access error

76

Path not found

91

Object variable set to Nothing

93

Invalid pattern

94

Illegal use of NULL

102

Command failed

429

Object creation failed

438

No such property or method

439

Argument type mismatch

440

Object error

901

Input buffer would be larger than 64K

902

Operating system error

903

External procedure not found

904

Global variable type mismatch

Siebel VB Language Reference

Version 6.0

Trappable Errors
About This Appendix

Table B-1.
Error code

Version 6.0

Error Numbers and Strings

(Sheet 3 of 3)

Error Text

905

User-defined type mismatch

906

External procedure interface mismatch

907

Pushbutton required

908

Module has no MAIN

910

Dialog box not declared

Siebel VB Language Reference

B-3

Trappable Errors
About This Appendix

B-4

Siebel VB Language Reference

Version 6.0

Derived Trigonometric Functions

A number of trigonometric functions can be written in Basic using the built-in


functions. The following table lists several of these functions:
Table C-1.

Version 6.0

Derived Trigonometric Functions

(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

HCotan(x) = (Exp(x)+Exp(-x))/ (Exp(x)-Exp(-x))

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

Siebel VB Language Reference

C-1

Derived Trigonometric Functions

Table C-1.

C- 2

Derived Trigonometric Functions

(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

Siebel VB Language Reference

Version 6.0

Glossary

call by reference

Arguments passed by reference to a procedure can be modified by the


procedure. Procedures written in Basic are defined to receive their
arguments by reference. If you call such a procedure and pass it a variable,
and if the procedure modifies its corresponding formal parameter, it will
modify the variable. Passing an expression by reference is legal in Basic; if
the called procedure modifies its corresponding parameter, a temporary
value will be modified, with no apparent effect on the caller.

call by value

When an argument is passed by value to a procedure, the called procedure


receives a copy of the argument. If the called procedure modifies its
corresponding formal parameter, it will have no effect on the caller.
Procedures written in other languages, such as C, can receive their
arguments by value.

comment

A comment is text that documents a program. Comments have no effect on


the program (except for metacommands). In Basic, a comment begins with
a single quote and continues to the end of the line. If the first character in
a comment is a dollar sign ($), the comment is interpreted as a
metacommand. Lines beginning with the keyword Rem are also interpreted
as comments.

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

A procedure that returns a value. In Basic, the return value is specified by


assigning a value to the name of the function, as if the function were a
variable.

Version 6.0

Siebel VB Language Reference

Glossary

label

A label identifies a position in the program at which to continue execution,


usually as a result of executing a GoTo statement. To be recognized as a
label, a name must begin in the first column and must be immediately
followed by a colon (":"). Reserved words are not valid labels.

metacommand

A metacommand is a command that gives the compiler instructions on how


to build the program. In Basic, metacommands are specified in comments
that begin with a dollar sign ($).

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

The system Siebel VB uses to determine which operators in an expression


to evaluate first, second, and so on. Operators with a higher precedence are
evaluated before those with lower precedence. Operators with equal
precedence are evaluated from left to right. The default precedence order
(from high to low) is numeric, string, comparison, logical.

procedure

A series of Siebel VB statements and functions executed as a unit. Both


subprograms (Sub) and functions (Function) are called procedures.

subprogram

A procedure that does not return a value.

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

Siebel VB Language Reference

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

too much data 3-358


upper bound of the subscript range 3-357
Asc function 3-22
Atn function 3-23
averaging
example 3-40, 3-72, 3-179
Null values in 3-229

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

Siebel VB Language Reference

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

Siebel VB Language Reference

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

Deftype statement 3-71


Dim statement 2-11, 2-17, 3-73
Dir function 3-79
directories
attributes 3-135
creating 3-213
removing 3-275
directory control, statements 1-7
disk control, statements 1-7
DLL (dynamic link library)
calling C procedures 3-29
named arguments, using 3-30
passed-in value 3-70
procedure, calling external 3-30
procedure, declaring 3-68
procedures, external 3-69
writing your own functions 3-128, 3-337
Do...Loop statement 3-81, 3-98
DoEvents statement 3-82
double data type, converting to 3-34
dynamic arrays
about 2-162-17
bounds, changing 3-263
freeing the storage 3-88
dynamic link library. See DLL (dynamic link
library)
dynamic string variables
declaring 3-146
types 3-77

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

Err function 3-91


Err statement 2-25, 3-92
Error function 3-94
error handling
about 2-24
error message, returning 3-94
error statements, list 1-6
routine, halting 3-271
routine, location 3-235
trappable B-1B-3
Error statement 3-96
errors
See also trapping errors
derived from an ODBC function call 3-310
trappable B-1B-3
Excel worksheets, opening 3-141
Exit statement 3-98
Exp function 3-99
Exponentiation operator 2-19
expressions
assigning to a Basic variable 3-191
comparing 3-173
comparing contents 3-193
converting to formatted string 3-114
described 2-182-20
External DLL procedures 3-69

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

Siebel VB Language Reference

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

Siebel VB Language Reference

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

IPmt function 3-169


IRR function 3-171
Is operator 3-173
IsDate function 3-174
IsEmpty function 3-175
IsMissing function 3-177
IsNull function 3-179
IsNumeric function 3-181

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

Siebel VB Language Reference

Index

Null function 3-229


null variants 2-18
numbers
negative/positive 3-301
square root 3-327
string representation 3-331
numeric conversions 2-15
numeric data types, list 2-12
numeric expressions
formatting 3-1153-119
integer part 3-109
numeric functions, statements 1-9
numeric operators 2-19
numeric value of first number 3-362
numeric variables, declaring 3-76, 3-145

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

Siebel VB Language Reference

Open statement 3-238


opening files 3-238
operating system events, processing with
Windows 3-82
operators 2-182-20
Option Base statement 3-241
Option Compare statement 3-244
Option Explicit statement 2-5, 3-246
OR operator 2-20
output line width 3-371

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

repeated characters 3-334


repetitive action, controlling 3-369
Reset statement 3-269
Resume Next parameter 2-25
Resume statement 3-271
Right function 3-273
RmDir statement 3-275
Rnd function 3-277
Rset statement 3-279
RTrim function 3-281
run-time error code
returning for last error trapped 3-91
setting 3-92
run-time errors
list of B-1B-3
trapping 2-28

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

programming conventions 2-82-10


supported uses Intro-4
Sin function 3-304
sine, calculating 3-304
single data type, converting to 3-52
sounds, emitting 3-24
Space function 3-305
spaces
leading 3-353
printing 3-306
returning 3-305
in strings 3-205
trailing 3-353
Spc function 3-306
SQL statements, executing 3-312
SQLClose function 3-308
SQLError function 3-310
SQLExecQuery function 3-312
SQLGetSchema function 3-314
SQLOpen function 3-317
SQLRequest function 3-320
SQLRetrieve function 3-322
SQLRetrieveToFile function 3-325
Sqr function 3-327
square root 3-327
statements
executing 3-288
executing on a variable 3-372
Help syntax Intro-6
Static statement 3-328
Stop statement 3-330
Str function 3-331
StrComp function 3-332
String concatenation operator 2-19
string conversions
described 2-15
statements 1-13
string data types
converting to 3-54
described 2-13
String function 3-334
string functions 1-12
string operators 2-19

Siebel VB Language Reference

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

Siebel VB Language Reference

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

Null value, determining 3-179


Null value, setting 3-229
types 3-363
VarType Function 2-17
VarType function 3-363
volume labels, attributes 3-135

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

Siebel VB Language Reference

Index

10

Siebel VB Language Reference

Version 6.0

You might also like