Help with first DLL

beans4you
04-02-2003, 07:26 AM
I have started creating a DLL as illustrated in the Tutorial Create ActiveX Dll (http://www.visualbasicforum.com/showthread.php?threadid=7290&highlight=%2Adll+tutorial), by JDT. I did exactly as he instructed. However, once I declared my variable as the DLL, I could not set it to a new instance of the DLL.

Example:

' CSomeDll is in the auto drop-down menu
dim pMyDLL as CSomeDll

' There is no instance of CSomeDll in the auto drop-down menu
set pMyDLL = New CSomeDll


I have also tried this:

' SomeDll.CSomeDll is in the auto drop-down menu
dim pMyDLL as SomeDll.CSomeDll

' There is no instance of CSomeDll or SomeDll in the auto drop-down menu
set pMyDLL = New CSomeDll


Anyone have any clues to what I might be doing wrong? If it helps I'm running VB6.0.

Thanks
- Eric

Squirm
04-02-2003, 07:29 AM
What is the name of your DLL project and what is the name of the class which you are trying to create an instance of? Is the DLL referenced? Be more specific about what's not working. Are you getting any errors?

beans4you
04-02-2003, 08:13 AM
Everything is the same as the tutorial.

File Name: SomeDll.dll
Project Name: SomeDll
Project Description: This is a useless DLL
UserDocument Name: CSomeDll

If I try this:

Private Sub cmdOK_Click()
Dim pLogin As CSomeDll

Set pLogin = New CSomeDll
Debug.Print pLogin.ReverseString("ABCD")
OK = True
End Sub

I get this error:

Compile Error:
Invalid use of new keyword.

If I try this:

Private Sub cmdOK_Click()
Dim pLogin As CSomeDll

Debug.Print pLogin.ReverseString("ABCD")
OK = True
End Sub

I get this error:

Run-time Error 91:
Object Variable or With block not set.


Here is all the code in the CSomeDll UserDocument:

Option Explicit

Public Function ReverseString(ByRef SomeString As String) As String

ReverseString = StrReverse(SomeString)

End Function


Yes the DLL is referenced.

Home this helps.

- Eric

Squirm
04-02-2003, 08:18 AM
You should be using a Class not a UserDocument

beans4you
04-02-2003, 08:24 AM
What do you know, I am a moron!

Works great, thanks for the help.

- Eric

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum