Code sample a (comsamplevb) – Rockwell Automation FactoryTalk Transaction Manager User Guide User Manual

Page 154

Advertising
background image

FactoryTalk Transaction Manager User Guide

154

10. Click Apply to save the parameters, then click Close to return to the

Configuration Checklist.

You are now ready to use Microsoft COM+ components in a FactoryTalk
Transaction Manager transaction.

Code Sample A (ComSampleVB)

The following code is referenced in the ―Creating the remote component‖
procedure.

Option Explicit

Public Function Get_VB_Sample_Data( _

ByVal strKeyID As String, _

Optional ByRef strData As String, _

Optional ByRef intData As Integer, _

Optional ByRef lngData As Long, _

Optional ByRef sngData As Single, _

Optional ByRef dblData As Double, _

Optional ByRef bytData As Byte, _

Optional ByRef dtData As Date, _

Optional ByRef bolData As Boolean) _

As Long

‘ Declare an object variable as ObjectContext

Dim ctxObject As ObjectContext ‘Required

On Error GoTo errorhandler

‘ Set the object variable using GetObjectContext()

Set ctxObject = GetObjectContext() ‘Required

‘ Put all business code below

strData = "VB Sample Data"

intData = 32767

lngData = 32768

sngData = 34.02823

dblData = 1797.69313

bytData = 255

dtData = Now()

bolData = True

Get_VB_Sample_Data = 0

‘ Keep all business code above

Advertising