You can call COM1 in COM2 by instantiating COM1 in COM2.
Here's a sample code:
COM2 Code:
Dim m_objCOM1 As COM1
Private Sub Class_Initialize()
Set m_objCOM1 = New COM1
'you can now call any public function/sub in COM1
'example:
'm_objCOM1.procProcessTransactions
End Sub
If COM2 fails, you can rollback transactions from COM1 by doing this:
1. Have a On Error routine in COM2
2. In COM1 have a procedure that will rollback transactions
(i don't know if your using ADO)
3. Call that routine in COM2, if COM2 fails.
Code in COM1:
Public Sub procRollbackTrans
'put your code here
End Sub
Code in COM2:
Dim m_objCOM1 As COM1
Private Sub Class_Initialize()
On Error GoTo ErrHandler
Set m_objCOM1 = New COM1
'put your code here
Exit Sub
ErrHandler:
m_objCOM1.procRollbackTrans
End Sub
If you are using MTS, above explanation by VBvader is
not usuafull. Because you should not use initialize events for MTS components.
Instead you can use MTS transaction using transactionobject.
in COM1
public sub call1()
dim obj as objectcontext
dim objcom2 as com2.class
obj = getobjectcontext()
set com2 = obj.createinstance("com2.class"
on error goto errl
'--- some operation
com2.call2()
obj.setcomplete
errl:
obj.setAbort
end sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.