In Visual Basic, you can connect to the registered object using its program ID (late binding). In Visual Basic 5 or later, you can also use its class name (early binding).
To access a PowerBuilder COM object in Visual Basic:
Do one of the following:
Declare an object and connect to it using its program ID:
Dim EmpObj As Object Set EmpObj = CreateObject("PB105.employee")
Add a reference to the generated type library for the PowerBuilder COM object to your project, then declare an instance of the object using its class name (in Visual Basic 5 or later):
Dim EmpObj As New CoEmployee
Check that the connection was established:
Dim response If EmpObj Is Nothing Then response = MsgBox("Creating Employee Object", vbOKOnly, "Error") End If
Access functions or properties of the object:
Dim units, time as Long Dim DoubleReturn as Double Dim StringReturn As String DoubleReturn = EmpObj.f_calcdayavg units, time StringReturn = EmpObj.f_teststring EmpObj.ll_hours = 37
Destroy the object:
Set EmpObj = Nothing