Professional Documents
Culture Documents
Two
Siebel VB Syntax
Introduction
Data Types
Dimensioning Variables
Operators
Decisions
Looping
Functions and Subroutines
Arrays in Siebel VB
Some Important VB Methods
Using Siebel Objects
Error Handling in Siebel VB
Comments in Siebel VB
Use an apostrophe ‘ At the
beginning of a line to make a single
line comment
Example:
‘This is a Comment
There are NO multi-line comments in
Siebel VB
Data Types
Numbers: Integers, Fractions
Strings
Dates/Times
Variant
Objects
Object Type
Siebel Objects: BusComp, PropertySet,
others
Siebel VB is a strong typed language
Operators
Mathematical Operators
+, -, *, /, \, Mod, ^
Conditional Operators
=, <>, <, >, <=, >=
Logical Operators
And, Or, Not
Assignment
=
Dimensioning Variables
Syntax:
Dim VarName As DataType
Examples:
Dim iScore As Integer
Dim bcContact As BusComp
Can Dim more than one variable in one
line:
Dim sLastName, sFirstName As String
Only last variable gets specified data type:
others are type Variant
Cannot initialize
Decisions: If
Syntax:
If Condition Then
‘Code to be executed if Condition is True
End If
Example:
If iScore < 60 Then
sGrade = “Fail”
End If
Simple Decision Making Construct
Decisions: Else
Syntax:
If Condition Then
‘Code to Execute if Condition is True
Else
‘Code to Execute if Condition is False
End If
Example:
If iScore < 60 Then
sGrade = “Fail”
Else
sGrade = “Passing”
End If
Decisions: Else If
Example:
If iScore < 60 Then
sGrade = “Fail”
Else If iScore >= 100 Then
sGrade = “Perfect”
Else
sGrade = “Passing”
End If
Decisions: Select Case
Used to make large nested if
structures more readable
Syntax:
Select VarName
Case FirstCase
Case NextCase
Case Else
End Select
Decisions: Select Case
Example:
Select Case iScore
Case Is < 60
sGrade = “Fail”
Case Is >= 100
sGrade = “Perfect”
Case Else
sGrade = “Passing”
End Select
Looping: For Loop
Syntax:
For iCounter = iStart to iFinish Step
iAmount
‘Code to execute each iteration of loop
Next iCounter
Example:
For iCtr = 1 to 10 Step 2
sStepNum = “Step Number: “ & Str$(iCtr)
Next iCtr
Looping: Do Loop
Syntax:
Do
‘Code to execute each iteration of the loop
Loop Until (While) Condition
Example:
iCtr = 0
Do
iCtr = iCtr + 1
sStepNum = “Step Number: “ & Str$(iCtr)
value
End Function
Functions
Example:
Function GetName () As String
Dim sName As String
sName = GetProfileAttr(“SPN_CA_NAME”)
GetName = sName
End Function
Calling Functions
Syntax:
Var = FuncName(Value)
SubName (FuncName(Value))
Example:
Dim sName as String
sName = GetName
Example 2:
FindValue(GetName)
‘FindValue is some other sub that takes a
string as a parameter
Arrays
Dimensioning:
Dim ArrayName (NumElements) As Type
Max 60 elements
Arrays can be multi-dimensional
Useful methods for arrays
ReDim: Used for dynamic arrays
LBound, UBound: Return lower or upper
bound of array
Erase: Reinitialize array
Some Important VB Methods
Now
Asc
Val
Str$
Left$, Mid$, Right$
File Handling in Siebel VB
Now
Returns Current Time and Date on
machine that the script is running on
Running Web Client or Wireless Web
Client, that is the Siebel Server that the
AOM is running on
Running Mobile Web Client or Dedicated
Web Client, that is the machine that
Siebel.exe is running on- the client’s
machine
Asc
Takes a string as argument
Returns the ASCII value of the first
char in the string
Useful for determining whether input
is valid – you can check to see if it is
an alphabetic character, a numeric
character, or anything else
Val and Str$
Val takes a String argument that is
made up of numbers (i.e. “10”) and
returns its numeric value
Str$ takes a numeric argument and
converts it to a string
String Manipulation
Left$ Takes a string and an integer
argument
Returns a substring of the string
passed in
Right$ is same, but returns the
substring from the right
Mid$ Takes a string and 2 integers. It
returns a substring of the length of
the second integer, starting at the
character indicated by the first
File Handling
Open Statement
Line Input Statement
Eof Function
Write Statement
Close Statement
Opening Files
Syntax:
Open “Path\Filename” For Input (Output)
As #
Examples:
Open “C:\MyFile.txt” For Input As #1
Open “.\log\Error.log” For Output as #3
Reading From Files
Easiest to Use Line Input Statement
See Also: Input Stmt, Input Function, Get
Stmt
Syntax:
Line Input #FileNum, VarName
Example:
Open “C\MyFile.txt” For Input As #1
Do While Not Eof(1)
Line Input #1, sTemp
#sXML = sXML & sTemp
Loop
Close #1
Eof Function
Takes the number of an open file as
argument
Returns true if file pointer is at the
end of the file
Write Statement
Writes Data to an open file
Syntax:
Write #FileNum, Value
Example:
Open “C:\MyFile.txt” For Output As #2
For iCtr = 0 to UBound(MyArray)
Write #2, MyArray(iCtr)
Next iCtr
Close #2
Close Statement
Always Make sure to close your files
after use!
Syntax:
Close #FileNum
Siebel Specific Objects
BusComp
BusObject
TheApplication
PropertySet
Service
Object
Error Handling in Siebel VB
Syntax:
On Error GoTo Label:
‘other code
Label:
‘Handle error here
Example:
On Error GoTo ErrHandler:
‘other code
ErrHandler:
‘Handle error here