Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot make Active X component work, please help :(

Status
Not open for further replies.

arniec

Programmer
Jul 22, 2003
49
0
0
US
I created an Active X DLL a few months ago in VB and it worked fine. Recently a crash left me without my VB files, but I had my code pasted from an e-mail. I have been trying to recreate the files but I don't know what I'm missing. The code should work because it's direct from the last version. I just don't know what I'm doing wrong.

In my DLL I have the project named ACAS400DLL. My class module inside is named GetLoanNum and the code in that class module is:

Code:
Public Num As String

Public Function GetLoanNum() As String

    On Error GoTo GetDllErr
   {Processing code removed}

                GetLoanNum = "123456789"
    
    Exit Function
    
GetDllErr:
    MsgBox Error(Err)
    Exit Function
    
    
End Function

Private Function isAllNums(testString As String) As Boolean

    Dim x As Integer
    
    isAllNums = False
    
    For x = 1 To Len(testString)
        Select Case Mid(testString, x, 1)
        Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
            isAllNums = True
        Case Else
            isAllNums = False
        End Select
    Next x


End Function

Then I try to instantiate this from a VB EXE which I call testdll. I have included a reference to the acas400.dll file. My code for that is:

Code:
Private o As acas400.GetLoanNum

Private Sub Command1_Click()
   Set o = New GetLoanNum
   Dim str As String
   
   str = o.GetLoanNum()  'return value from function
   MsgBox str

End Sub

If I make the reference to the old DLL file (which I have compiled but lost the code for) the testdll.exe works fine, but if I use the newly created DLL code I get an error on the line
Code:
Set o = new GetLoanNum
that error is: Run Time Error 429: ActiveX component can't create object

I have been working on this checking and double checking every setting in my DLL, since the problem must be in the DLL, not the testdll.exe, but I can't make it work.

Please, I'm begging, help???
 
Please disregard, I had my code in a class module and not in a module; moving it fixed my problem.

Thanks anyways!
 
In case you're interested, you can open your dll project and select "Add Project" from the file menu. Then you can add a Standard Exe project in, and save both as a group. In the exe project, you can set a reference, not to the dll file, but to the vbp file. (In your case, to ACAS400DLL.vbp.) Then, you can step seamlessly through your test code and your class code.

When you save this, you will also save a vbg (Project Group) file, which you can then use to open both projects again.

One more thing: if you do this, make sure to right click on the exe project, in the project explorer (top right window on screen) and select Set as Startup.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top