+ Reply to Thread
Results 1 to 5 of 5

VBA Argument pass to DLL Issue

  1. #1
    Registered User
    Join Date
    03-27-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA Argument pass to DLL Issue

    Hello,

    So I'm completely new to VBA and I've written a DLL to do some functions and the idea is to pass the results back to Excel. The DLL works fine, I've tested it extensively. The issue is the last argument I pass to it from VBA in Excel, no matter what value it is, always gets passed as the same, very large number. Below is the VBA code and then the DLL function declaration. Help would be greatly appreciated I have no clue what's going on here. The last two arguments are to be passed as number values, both are passed in the same way, and the first works, the second doesn't.

    VBA Code:
    Please Login or Register  to view this content.
    And here's the function definition from the .h file for the DLL:
    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Argument pass to DLL Issue

    Have you checked what the value is in C2 on the sheet 'LMM'?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    03-27-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Argument pass to DLL Issue

    Yes, I can MsgBox(np) and it gives the correct value, but when I'm debugging and check the value once it's passed into the DLL it's completely different. What's weird is if I switch the ordering - pass in the np where the sz is and vice-versa, then the np is passed in fine but the sz is that same large number, which is really baffling.

  4. #4
    Registered User
    Join Date
    03-27-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Argument pass to DLL Issue

    Here's what's really weird. I tacked on another variable for the DLL function as a test/dummy variable. Then I pass np in both, in the first pass it gives the same large value - in the second the correct value. For some reason there's something off with the 6th argument, just that one.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Argument pass to DLL Issue

    can you register the .dll and set a reference to it and then call it without the declare? does it work then?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Registered User
    Join Date
    03-27-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Argument pass to DLL Issue

    Well the DLL isn't designed to be registered / doesn't have the proper register/unregister functions but I can try. In the meantime does anyone else have any ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. pass control as argument
    By horbay in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-17-2011, 09:04 AM
  2. Pass argument to SetSourceData
    By khdani in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-22-2008, 07:54 AM
  3. [SOLVED] Pass function as argument to UDF
    By Ron Rosenfeld in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-09-2006, 08:55 AM
  4. Pass Argument?
    By Hal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2005, 01:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1