How to use a PB DLL in VB6? 
Author Message
 How to use a PB DLL in VB6?

--
Hi all,
I Try to learn how to call a Dll from VB6.
Here is the DLL I created with PB DLL6:
'********************************
'
'X2.DLL
'
'Written by: Philippe Lhermie, le 11/11/99
'
'Description: Premiere DLL pour utilisation dans VB6,
'elle multiplie par 2
'
'********************************
#COMPILE DLL

OPTION EXPLICIT

FUNCTION Fois2(BYVAL X AS DOUBLE  ) EXPORT AS DOUBLE
            Fois2 = X*2
END FUNCTION

~~~~~~~~~~~~~~~~~~~~
I tried the following declaration in VB:
The result of the function has to be displayed in a Label.

Option Explicit
Private Declare Function Fois2 Lib "X2" (ByVal X As Double) As Double

Dim Resultat
Private Sub CmdOk_Click()
    Resultat = Fois2(5)
    LblResult.Caption = Resultat
End Sub

    When I try to reference myVB project to my DLL, I indicate the path, I
find it, but VB6 doesn't accept.
When I try to execute the  project
I get Error#453          "cannot find entry point of Fois2 in X2.DLL"

Regards,
Philippe






Tue, 30 Apr 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?
Philippe, Where the hell is your DLLENTRY point ????
Can't work so.......
Here a short Example:

GLOBAL hInst AS LONG
FUNCTION LibMain(BYVAL hInstance AS LONG, _
                 BYVAL Reason AS LONG,_
                 BYVAL Reserved AS LONG) EXPORT AS LONG

  hInst = hInstance

END FUNCTION
-----------------------------------------------------------------
Greets Michael Neitzel, Windows NT Filesystem Developer

Quote:

>#COMPILE DLL

>OPTION EXPLICIT

>FUNCTION Fois2(BYVAL X AS DOUBLE  ) EXPORT AS DOUBLE
>            Fois2 = X*2
>END FUNCTION

>~~~~~~~~~~~~~~~~~~~~



Tue, 30 Apr 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?

Quote:

> --
> Hi all,
> I Try to learn how to call a Dll from VB6.
> Here is the DLL I created with PB DLL6:
> FUNCTION Fois2(BYVAL X AS DOUBLE  ) EXPORT AS DOUBLE
>             Fois2 = X*2
> END FUNCTION

Phillippe, to export a function as mixed case, you have
to create it with an alias that is mixed case. Otherwise,
PB exports it as all upper case, i.e. "FOIS2". This had
me stumped for a couple of hours in the first DLL I wrote
with PB.

So either call it as "FOIS2" in the calling app, or export
it as "Fois2" like so:

FUNCTION Fois2 ALIAS "Fois2"(BYVAL x AS DOUBLE) EXPORT AS DOUBLE

Good luck...

- Troy King



Tue, 30 Apr 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?

Quote:
> Philippe, Where the hell is your DLLENTRY point ????
> Can't work so.......

A DLL Entry point is NOT required with PB/DLL.

--Dave



Tue, 30 Apr 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?

Quote:
> I Try to learn how to call a Dll from VB6.
> Here is the DLL I created with PB DLL6:

I see that the other folks have already mentioned the mixed-case issue
and the lack of a DllEntry point, so I'll skip that.

Quote:
>     When I try to reference myVB project to my DLL, I indicate the path, I
> find it, but VB6 doesn't accept.

Paths to DLLs, with VB, are a problem. I'm not sure about VB6 in
specific, but I've had problems before with trying to specify a path to a
DLL in Visual Basic. Ideally, to avoid this, you want to do one of two
things: either put the DLL in the same location as the program that
uses it, or put it in the Windows system directory. With a 32-bit DLL,
depending on the version of Windows, the typical directory would be
either C:\WINDOWS\SYSTEM or C:\WINDOWS\SYSTEM32. The
latter directory would be appropriate for NT, and probably for Win2000,
and maybe for Win98. (I haven't seen any explicit information on this
so far, but Windows 98 does seem to have a SYSTEM32 folder, so I'd
guess that it may follow a similar approach.)

I think there's a Windows API call to find out the system directory but,
as usual, MSDN is letting me down: too many items, too badly
cross-referenced. Anyone used this call recently?



Wed, 01 May 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?
On Sat, 13 Nov 99 07:21:14 GMT, "Tom Hanlin"

Quote:

>Paths to DLLs, with VB, are a problem. I'm not sure about VB6 in
>specific, but I've had problems before with trying to specify a path to a
>DLL in Visual Basic. Ideally, to avoid this, you want to do one of two
>things: either put the DLL in the same location as the program that
>uses it, or put it in the Windows system directory.

A word of warning; If you're planning on running the app from a CD you
could have problems with the DLL not being found even though it's in
the same directory as the EXE.  I've been told this is due to the way
Windoze handles CD file access- something about creating a temporary
image in memory and referencing that instead of the actual CD.

- Shawn



Tue, 07 May 2002 03:00:00 GMT  
 How to use a PB DLL in VB6?

Quote:
> A word of warning; If you're planning on running the app from a CD you
> could have problems with the DLL not being found even though it's in

Is this somewhat confirmed by trial and error, or documented?
It would be a pity if it was. Thoug someone out there probably know how
to run aroun this.

---
~8o)  Haakon



Tue, 07 May 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. email enable PB/DLL-PB/CC using Outlook

2. MX Lookup with PB/CC or PB/DLL

3. TCPADDR for PB/DLL & PB/CC

4. Info on new PB/CC and PB/DLL

5. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

6. animated characters, speech input/output in PB/DLL and PB/CC

7. SQL, ADO/OLE-DB programming in PB/DLL and PB/CC

8. Pb with 2 parallel VIs using same DLL

9. Calling Clarion DLL from VB6

10. Calling Fortran DLL with char args from VB6

11. Importing VB6 code to VB.NET calling FORTRAN .DLL lessons learned

12. DLL callback to VB6

 

 
Powered by phpBB® Forum Software