|
-
Oct 27th, 2000, 10:47 AM
#1
Thread Starter
Lively Member
I have created a dll with one public function and numerous
private functions.
(The public function's name is the same as the dll but
different from the project name.)
To test it I created an application, referenced the dll and
then called the dll's public function. When I try and
compile the executable I receive an error:
"Sub or Function not defined".
The application and dll are in the same directory, why
can't it find the function?
A big "Thank You" to anyone who can help me with this!
-
Oct 27th, 2000, 10:52 AM
#2
Frenzied Member
I'm not sure what your saying but to access your dll function :
yourdll.yourfunction
it's that simple!!
-
Oct 27th, 2000, 11:14 AM
#3
Thread Starter
Lively Member
Thanks, your answer got me over one hurdle and on to another:
My Dll is named CreateCallSum.dll, the project is named
CreateCallSum and the public function is called CreateRpt
My application calls it with:
blnStatus = CreateCallSum.CreateRpt
It doesn't seem to have a problem with the CreateCallSum.
part but now I get a "Method or Data member not defined"
error at the CreateRpt part.
Suggestion?
-
Oct 27th, 2000, 12:10 PM
#4
What is the name of the class?
Lets say the class is named MyClass, then you can use the following code (providing you added a reference to the dll)
Dim x as CreateCallSum.MyClass
Set x = CreateObject("CreateCallSum.MyClass")
blnStatus = x.CreateRpt
-
Oct 27th, 2000, 01:17 PM
#5
Thread Starter
Lively Member
I'm not creating an object.
I created a dll with 1 public function.
I pass variables into it; it forms an sql statement,
queries the database and passes back a formatted string
with the data found.
For instance:
I have GetValue.dll with the following function:
Public function MyDLLFunction(byValintOne as integer, _
byRef strTwo as string) as boolean
if intOne = then
strTwo = "Value 1"
else
strTwo = "Value2"
end if
Myfunction = true
end function
-------
In my application I reference GetValue.dll and call it in
my code:
Private strValue as string
Private Sub btnTest_Clicked
dim blnStatus as boolean
blnStatus = MyDLLFunction(1, strValue)
End Sub
-------
How should I call this function?
I would like to call this function like I would the Format function.
Thanks
-
Oct 27th, 2000, 01:35 PM
#6
I assume you created the dll with visual basic. Unless you set the Instancing property of the class that contains the function to GlobalMultiUse, you need to create an object before you can use the function.
If you set the Instancing property to 6 - GlobalMultiUse you can call the function like you wanted, it acts like an intrinsic vb function. In fact vb creates the object for you, you don't need to do it yourselve.
-
Oct 27th, 2000, 03:00 PM
#7
Thread Starter
Lively Member
I used your suggestion and changed the Instancing property
to 6 - GlobalMultiUse.
I then declared the function
Private Declare Function MyDLLFunction Lib "GetValue" (byVal intOne as integer, byRef strTwo as string) as boolean
I can now compile my application without errors but when
I try to run it I receive this error:
453 -> Can't find DLL Entry point MyDLLFunction in GetValue
The help file says the problem is that MyDLLFunction cannot
be found in the DLL so I delete the dll and recompiled.
But it didn't solve the problem.
I am absolutely frustrated.
In C I would simply add the dll into the make file. In VB6 I just do not have a clue.
-
Oct 27th, 2000, 03:16 PM
#8
You must NOT declare a function that is in a COM dll. You must add a reference to the dll (project --> references).
Only functions from standard C dll's are declared.
-
Oct 27th, 2000, 04:19 PM
#9
Thread Starter
Lively Member
Alrighty then,
I took the Declare statement out and now find error 429:
ActiveX component can't create object.
I then checked the help and it told the dll had to be registered. So I registered it. Checked the registry to make
sure it pointing to the right directory. I'm not creating
an object so the other 'possible reasons' are mute and
still a recieve Error 429.
This should be so simply yet nothing works.
-
Oct 27th, 2000, 04:51 PM
#10
Check you're references again. If you don't have set binary compatibility on you're dll project, you generate new clsid's every time you compile your dll. This means that every time you compile your dll, you have to set the reference again to your new dll, otherwise the project using the dll is still poining to the old dll, which doesn't exist anymore (at least the registry settings are overwritten). You should not have to register the dll manually, since this is done when you compiled it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|