Results 1 to 11 of 11

How can I receive the multi return values from DLL in VBA(Excel Visual Basic)?

Threaded View

  1. #1
    Registered User
    Join Date
    03-10-2017
    Location
    London
    MS-Off Ver
    2016
    Posts
    29

    How can I receive the multi return values from DLL in VBA(Excel Visual Basic)?

    Now, I'm currently trying to receive the multiple return value from DLL in VBA(Excel Visual Basic).

    This is my DLL code.

            double _stdcall pll_dll(double* datain0, double* datain1, double* dataout0, double* dataout1)
        {
        	dataout0[0] = datain0[0]+10;
        	dataout1[0] = datain1[0]+10;
        
        	return 0;
        }
    Then I want to give some value to the DLL by using the datain0 and datain1 and receive the dataout0 and dataout1 from the DLL in the VBA(Excel Visual Basic).

    This is my VBA code.actually, I'm not familiar with VBA(Excel Visual Basic)

    
        Option Explicit
        
        
        Private Declare PtrSafe Function pll_dll Lib "F:\work\pll_dll\x64\Debug\pll_dll.dll" (ByRef x_in As Double, ByRef y_in As Double, ByRef x_out As Double, ByRef y_out As Double) As Double
        Dim Error As Integer
        Dim dat0 As Double
        Dim dat1 As Double
        Dim dat2 As Double
        Dim dat3 As Double
        
          
        Function pll_dll_excel(data0 As Double, data1 As Double, data2 As Double, data3 As Double) As Double
        
              pll_dll_excel = pll_dll(data0, data1, data2, data3)
        End Function
        
        
        Sub useSquareInVBA()
           MsgBox pll_dll_excel(3, 4, Cells(5, 5), Cells(6, 6))
        End Sub
    What am I supposed to make the function which is what I want to give datain0=3, datain1=4 and receive the dataout0 and dataout1 values?
    If I run the above code in the excel, I've got a problem halt
    Last edited by u24c02; 03-10-2017 at 08:50 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Macro - Visual Basic - Send command to serial port - Receive Data.
    By reiiling in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2017, 09:37 AM
  2. [SOLVED] Can I run Visual Basic procedure using Excel Visual Basic editor?
    By john.jacobs71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-26-2005, 10:25 AM
  3. Excel in Visual Basic
    By Spike in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2005, 02:15 PM
  4. Visual Basic Multi-Stepped process
    By MK@Hartford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2005, 01:35 PM
  5. Replies: 1
    Last Post: 09-13-2005, 07:06 AM
  6. converting formulas into values using a macro in visual basic edit
    By F.C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2005, 05:05 AM
  7. visual basic in excel -
    By DKehl in forum Excel General
    Replies: 2
    Last Post: 03-23-2005, 04:06 PM

Tags for this Thread

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