Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
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 object—typically 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.resetNOTE: If you omit the keyword Set when assigning an object variable, Siebel VB tries to copy the default member of one object to the default member of another. This usually results in a run-time 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,
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, read 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
`Opportunities exist for the Account - Delete is not allowed
iReturn = CancelOperation
end if
End WithBusComp_PreDeleteRecord = iReturn
Set oBC = Nothing
Set oBO = NothingEnd Function
See Also
CreateObject Function
Is Operator
Me
New Operator
Nothing Function
Object Class
Typeof Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |