Link to home
Start Free TrialLog in
Avatar of bsardeson
bsardeson

asked on

Error using VB6 Custom DLLs when creating references

I have created two VB6 SP6 custom DLLs.  BOTH DLLS reference two classes, cPoint and cPoints.

In the code below, Calling Sub CreateShell, the oPoints1 and oPoint objects function correctly and are instantiated against ShellPoints1 classes with the new oPoint = {0,0,0}, then changing to the new values later works too.

Next I am Calling Sub CreateSubShell, the SET oDP = oPoints1 reference works, but the code fails on oPoint.pt3D = oDP('p1").pt3D.  Error 430 - class automation error

In the watch window, oDP("p1").pt3D have values as set in the previous SUB while oPoint = nothing in the watch, but should = {0,0,0} after being instantiated.  No error on the instantiation, just during the set = line.

That said ... can a single project reference two different DLLs that have the same class names?  IF NOT, where could I find information regarding how to use DLLs properly?  Google and the EE search were fairly useless researching this.
Option Explicit
'Custom DLL References'
Dim oPoints1 As New ShellPoints1.cPoints
Dim oPoints2 As New ShellPoints1.cPoints

Private Sub CreateShell()
    'Custom DLL References'
    Dim oPoint As New ShellPoints1.cPoint

    oPoint.pt3D = MakePoint(15#, 280#, 10#)
    oPoints1.Add oPoint, "p1"

    Call CreateSubShell
End Sub

Private Sub CreateSubShell()
    'Custom DLL References'
    Dim oDP As ShellPoints1.cPoints
    Set oDP = oPoints1

    Dim oSDP As ShellPoints2.cPoints
    Dim oPoint As New ShellPoints2.cPoint
    
    oPoint.pt3D = oDP("p1").pt3D
    oSDP.Add oPoint, "pRake1"
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HooKooDooKu
HooKooDooKu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bsardeson
bsardeson

ASKER

The Binary Compatibility was an issue however, I had further problems, so I have just reverted to having multiple instances of a single custom dll, which the AutoCAD VBA 5 seeme to appreciate better, the code also processes nearly 100% faster using the singular DLL.

Thanks!
To extend HooKooDooKu explanation:
While I actually had binary compatability so to speak when I compiled in the VB6 IDE, I didn't while referencing in the VBA IDE.  Both projects were referencing the same dll name, not each projects dll name:

ShellPoint1.dll binary compat with ShellPoint1.dll
ShellPoint2.dll binary compat with ShellPoint1.dll

Therefore the Error 430 appeared because these Statements were EQUAL ... whoops!  
    Dim oPoint As New ShellPoints1.cPoint =  Dim oPoint As New ShellPoints2.cPoint

I was actually attempting to assign the cPoint oDP("p1").pt3D  to the same memory space with this statement, oPoint.pt3D = oDP("p1").pt3D,  in the second subroutine.

And my solution code using a single custom dll with multiple references:

 
Option Explicit
'Custom DLL References'
Dim oPoints1 As New ShellPoints1.cPoints
Dim oPoints2 As New ShellPoints1.cPoints
Dim oPoints3 As New ShellPoints1.cPoints
Dim oPoints4 As New ShellPoints1.cPoints
Dim oPoints5 As New ShellPoints1.cPoints

Private Sub CreateShell()
    'Custom DLL References'
    Dim oPoint As New ShellPoints1.cPoint

    oPoint.pt3D = MakePoint(15#, 280#, 10#)
    oPoints1.Add oPoint, "p1"

    Call CreateSubShell
End Sub

Private Sub CreateSubShell()
    'Custom DLL References'
    Dim oDP As ShellPoints1.cPoints
    Set oDP = oPoints1

    Dim oSDP As ShellPoints1.cPoints, oSDP1 As ShellPoints1.cPoints
    Dim oSDP2 As ShellPoints1.cPoints, oSDP3 As ShellPoints1.cPoints

    Set oSDP = oPoints2: Set oSDP1 = oPoints3: Set oSDP2 = oPoints4: Set oSDP3 = oPoints5:
    
    Dim oPoint As New ShellPoints1.cPoint
    
    oPoint.pt3D = oDP("p1").pt3D
    oSDP.Add oPoint, "p1": Set oPoint = New ShellPoints1.cPoint

    oPoint.pt3D = oSDP("p1").pt3D
    oSDP1.Add oPoint, "p1": Set oPoint = New ShellPoints1.cPoint

    oPoint.pt3D = oSDP1("p1").pt3D
    oSDP2.Add oPoint, "p1": Set oPoint = New ShellPoints1.cPoint

    oPoint.pt3D = oSDP2("p1").pt3D
    oSDP3.Add oPoint, "p1": Set oPoint = New ShellPoints1.cPoint

    oPoint.pt3D = oSDP3("p1").pt3D
    oSDP4.Add oPoint, "p1": Set oPoint = New ShellPoints1.cPoint
End Sub

Open in new window