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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Question: VB DLL Called from VB? 2

Status
Not open for further replies.

swatman

Programmer
Feb 24, 2003
9
EE
Hi,

a basic question this one, I'm sure...

I wish to put code in a VB DLL. It is declared as Public thus:

Public Sub mysub()
MsgBox "Hello world"
End Sub

In the client app, it is declared as:
Public Declare Sub mysub Lib "testdll" ()

However I get error 453, entry point not found. I have done a VC++ DLL in VB, and thought VB DLL to VB should be easier.

Can someone help?

thanks...


 
Set up a class in your dll with the function you described above. Then from VB declare the class (of the dll) as a variable

dim oClass as dllname.dllclass

Create a new instance of this variable.

Set oClass =New dllname.dllclass

Then call the procedure, qualified with the class variable.

oClass.mysub

Thanks and Good Luck!

zemp
 
Follow zemp's advice; VB creates COM DLLs, not 'classic' DLLs
 
thanks Zemp,

I have been banging my head on this one for a week.

So, VB DLLs will not export functions and Subs. Rather, only methods of Classes may be exported.

Something else I found, it seems that you do not need to instantiate an instance of your DLL service to call the method.

ie in the DLL, I have a class with:
Public Sub mySub()
msgbox "Hello World"
end Sub

It can be called from the client App as below:

sub Commmand_Click()
myObj.mySub
' or...
mySub
end Sub

So even if it does not allow you to create traditional 3GL functions and subs, the methods can be called as if they were functions or subs.
 
Interesting, never tried it without the qualifying object variable. Probably a case of 'if it ain't broke don't fix it'.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top