I'm having strange problems with the creation of ActiveX objects.

I try to create a very two simple and small code examples that explains my problem:
- One that don't uses a suplementary ActiveX control ---> Works fine.
- Another that uses a suplementary ActiveX control ---> Don't works after some time.


Please give me some help!

Thanks in advance,
Rui Sousa



'----------------------------------------------------------------
' If i do the things like this works fine
'----------------------------------------------------------------

(Project.exe)

Private Sub Form_Load()
Dim i As Integer
Dim SAPBAPIControl1 As Object

On Error GoTo Func_Error

i = 1
Do While i < 1000000000
If Not SAPLogon(SAPBAPIControl1) Then GoTo Func_Error ' Do a SAP connection
If Not SAPLogoff(SAPBAPIControl1) Then GoTo Func_Error ' Do a SAP Connection
i=i+1
Loop
Func_Error:
End
End Sub



'----------------------------------------------------------------
' If i do the things like this after some while (10 min) starting
' having extrange problems with the SAP connections.
'
' My first guess is memory problems (don't free objects)
' But i can't fugure out why????
'----------------------------------------------------------------

(Project.exe)

Private Sub Form_Load()
Dim objComponent As Object
Dim i As Integer

On Error GoTo Func_Error

i = 1
Do While i < 1000000000
Set objComponent = CreateObject("Test.ClassExample")

If Not objComponent.Start() Then GoTo Func_Error

Set objComponent = Nothing
i=i+1
Loop
' I already try create the objComponent just one time but the problem remains

Func_Error:
End
End Sub



(Test.dll - ClassExample.cls)

Private Sub Start()
Dim SAPBAPIControl1 As Object

If Not SAPLogon(SAPBAPIControl1) Then GoTo Start_Error
If Not SAPLogoff(SAPBAPIControl1) Then GoTo Start_Error

Start = True
Start_Exit:
Exit Sub
Start_Error:
Start = False
If Err.Number = 0 Then
GoTo Start_Exit
Else
Resume Start_Exit
End If
End Sub