Visual Basic Demonstration Programs


If you have a Visual Basic project group containing both the COM client and the server, the interceptor component might not work properly if you try to debug the projects from inside the Visual Basic project group. Separating the client and the server to different Visual Basic projects, or running the executables with the adapter should resolve this scenario.
These exercises assume that you will use sample as the name of the dat file, and also assumes that you will save sample.dat to the directory C:\tibco\adapter\adcom\5.3\examples. If you save it to a different directory, you must update the path in the testinterceptor.dsw and rebuild your COM client before you import the metadata into the project file.

VBOperationDemo

This is a Visual Basic Application.

  1. Open the VBOperationDemo project in the examples\Demos\VBOperationDemo directory.
  2. Build the VBOperationDemo project, causing the executable VBInterceptorDemo.exe to be generated.
  3. Start the service component of the adapter.
  4. Run VBOperationDemo.exe. It will perform the following actions:
    1. Call GetObject to obtain an ITestobj1 interface. Recall that this interface is actually an interceptor proxy.
    2. Call the method ToUpper on the ITestobj1 interface. This method will result in a TIBCO ActiveEnterprise operation request being sent over TIBCO Rendezvous. This operation request will be received and processed by the service component.

Code

All the code for the VBOperationDemo project is listed below:

Dim objTestobj1 As Testobj1 
Private Sub Form_Unload(Cancel As Integer) 
Set objTestobj1 = Nothing 
End Sub 
 
Private Sub Form_Load() 
Set objTestobj1 = 
GetObject("tibco:c:\tibco\adapter\adcom\5.3\examples\sample.dat|Ad
apter for COM/Interceptor 
Instances/TIBCOCOMInterceptor1|Operation2.Testobj1") 
End Sub 
 
Private Sub Invoke_Click() 
If Len(Text1.Text) Then 
  Let Text2.Text = objTestobj1.ToUpper(Text1.Text) 
End If 
End Sub 

VBPubSubDemo

This is a Visual Basic Application.

  1. Open the VBPubSubDemo project in the examples\Demos\VBPubSubDemo directory.
  2. Build the VBPubSubDemo project, causing the executable VBPubSubDemo.exe to be generated.
  3. Start the service component of the adapter.
  4. Run VBPubSubDemo.exe. It will perform the following actions:
    1. Call GetObject to obtain an ITestobj3 interface. Recall that this interface is actually an interceptor proxy.
    2. Call the method TestPublishComplexTypeInVARIANT three times when you click the Send button, passing a UDT and a couple of SAFEARRAY's through the VARIANT parameter ip1. This method will result in the UDT and SAFEARRAY's being published by the Publication Service in the Interceptor and received by the Subscription Service in the service. The UDT will be published as a TIBCO ActiveEnterprise MInstance, while the SAFEARRAY's will be published as TIBCO ActiveEnterprise MSequences.

      It is not possible in Visual Basic to pass a UDT or a SAFEARRAY by value, that is, as an <in> parameter. Visual Basic requires that UDTs and SAFEARRAY's be passed by reference, that is, as <in,out> parameters. Passing <in,out> parameters, however, runs contrary to the entire notion of publish/subscribe, which is one-way in nature.

      This project shows how to overcome this problem. You pass the UDT or SAFEARRAY inside a VARIANT, which Visual Basic does allow to be passed by value (as an <in>) parameter. This project also shows how you can pass a variety of documents (MInstances or MSequences) through a single method: simply pass them inside a VARIANT.

Code

All the code the for the VBPubSubDemo project is listed below:

Dim objTestobj3 As Testobj3 
Private Sub Send_Click() 
 
' Publish a UDT in a VARIANT 
Dim varUDTSimple1 As OLEAutomationCompatibleUDTSimple 
Let varUDTSimple1.m_vui1 = 1 
Let varUDTSimple1.m_vi2 = 2 
Let varUDTSimple1.m_vi4 = 4 
Let varUDTSimple1.m_vint = 4 
Let varUDTSimple1.m_vboolean = True 
Let varUDTSimple1.m_vr4 = 4.4 
Let varUDTSimple1.m_vr8 = 8.8 
Let varUDTSimple1.m_vfixed = 1.1 
Let varUDTSimple1.m_vdateTime = Now 
Let varUDTSimple1.m_vstring = "abc" 
Call objTestobj3.TestPublishComplexTypeInVARIANT(varUDTSimple1) 
 
'Publish a SAFEARRAY of Floats in a VARIANT 
Dim varLongArray(1) As Single 
Let varLongArray(0) = 1.1 
Let varLongArray(1) = 2.2 
Call objTestobj3.TestPublishComplexTypeInVARIANT(varLongArray) 
 
'Publish a SAFEARRAY of UDT's in a VARIANT 
Dim UDTSimpleArray(1) As OLEAutomationCompatibleUDTSimple 
Let UDTSimpleArray(0).m_vui1 = 1 
Let UDTSimpleArray(0).m_vi2 = 2 
Let UDTSimpleArray(0).m_vi4 = 4 
Let UDTSimpleArray(0).m_vint = 4 
Let UDTSimpleArray(0).m_vboolean = True 
Let UDTSimpleArray(0).m_vr4 = 4.4 
Let UDTSimpleArray(0).m_vr8 = 8.8 
Let UDTSimpleArray(0).m_vfixed = 1.1 
Let UDTSimpleArray(0).m_vdateTime = Now 
Let UDTSimpleArray(0).m_vstring = "abc" 
Let UDTSimpleArray(1).m_vui1 = 1 
Let UDTSimpleArray(1).m_vi2 = 2 
Let UDTSimpleArray(1).m_vi4 = 4 
Let UDTSimpleArray(1).m_vint = 4 
Let UDTSimpleArray(1).m_vboolean = True 
Let UDTSimpleArray(1).m_vr4 = 4.4 
Let UDTSimpleArray(1).m_vr8 = 8.8 
Let UDTSimpleArray(1).m_vfixed = 1.1 
Let UDTSimpleArray(1).m_vdateTime = Now 
Let UDTSimpleArray(1).m_vstring = "abc" 
Call objTestobj3.TestPublishComplexTypeInVARIANT(UDTSimpleArray) 
 
End Sub 
Private Sub Form_Load() 
 
Set objTestobj3 = 
GetObject("tibco:c:\tibco\adapter\adcom\5.3\examples\sample.dat|Ad
apter for COM/Interceptor 
Instances/TIBCOCOMInterceptor1|Operation2.Testobj3") 
 
End Sub 
Private Sub Form_Unload(cancel As Integer) 
 
Set objTestobj3 = Nothing 
 
End Sub 
 

TIBCO Adapter™ for COM User’s Guide
Software Release 5.3, September 2005
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com