Thread: Hai Everybody !VC dll in VB ?

  1. #1
    Registered User
    Join Date
    May 2002

    Unhappy Hai Everybody !VC dll in VB ?

    How to use a regular dll create using MFC Dll wizard in a vb application.

    I 've created a small dll by name sum(int,int) which returns an integer .

    I want to use this function in VB application.

    I will be glad if any body can help,

  2. #2
    Registered User
    Join Date
    May 2003
    Well, this is the way I did it:

    1. Make sure you use WINAPI as the calling convention for the functions you want to export (i.e. make available from VB), like this:
    double WINAPI myFunc(double myVar)
    2. Add a def file to your project - it's just a text file like this:
    Make sure there's an entry for each function you want to export.
    3. In VBA (probably the same in VB) put something like this in the declarations area:
    Declare Function myFunc Lib "myDLL" (ByVal myVar As Double) As Double
    Make sure your DLL is in your system directory.

    I think that on 32-bit versions of Windows ints are 2 bytes in VB but 4 bytes in C, so you'll have to use short in your C code instead of int. Is there a 'cleaner' way of doing this? I don't know, I'm new to this.

    Hope that helps.


  3. #3
    id id
    Use the long type in VB.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DLL Error with VB .NET Program
    By willc0de4food in forum Windows Programming
    Replies: 6
    Last Post: 04-09-2005, 02:38 PM
  2. Passing an Array of Strings from VB to a C DLL
    By mr_nice! in forum Windows Programming
    Replies: 9
    Last Post: 03-08-2005, 06:16 AM
  3. Calling a VB DLL w/ forms from C++ DLL
    By UW_COOP in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2003, 08:04 AM
  4. Accessing varibles in a DLL from VB in run-time.
    By Dirty Sanchez in forum Windows Programming
    Replies: 1
    Last Post: 04-27-2003, 11:25 AM
  5. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 03:13 AM