473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

C++ DLL (callable from VBA and receiving Range data)

1
I am getting sick to figure out how to build a .dll to call in VBA and make possible my customized formulae. I want to make a .dll because of performance timing and so I started to study C++. As every project I've begun face issues after issues specially with the Range object to pass from VBA to my .dll.

Brief over my project: with Visual Studio 2019 I built a project with one file .cpp and another .def to EXPORT my functions.

Everything went right when I have to pass from VBA simple double arguments, but when I should pass a Range of Cells, I started to face seriuos annoing problem which block my project.

Actually, I read too many forums and also section of Dalton's books to handle my issues, but anything it's really clear to me.

I found something which talks about COM and API C, other about "ExportImport.cpp", SAFEARRAY and VARIANT type (the latter: I could figure out how to pass arguments from VBA to C++ dll, but still don't understand how to achive and use single element and specially return them).

If it's not too annoing for some of you, I would like a specific description of what to do in this case.

Thank you

Here my project which is called square and has two functions square and my _array:

.cpp file
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cmath>
  3. #include <OAIdl.h>
  4.  
  5. double __stdcall square(double& x)
  6. {
  7.     return x * 2;
  8. }
  9.  
  10. VARIANT __stdcall my_array(VARIANT *p)
  11. {
  12.     //my statements and operation on the array (Range received from VBA)
  13. }
  14.  
.def file

Expand|Select|Wrap|Line Numbers
  1. LIBRARY "square"
  2. EXPORTS 
  3. square @1
  4. my_array @2
  5.  

SPECIALLY, I WOULD UNDERSTAND HOW TO PASS A RANGE FROM VBA TO THE FUNCTION "my_array" AND HOW TO MANGE EVERY ELEMENT OF THE RANGE I PASSED
Jan 9 '20 #1
0 1820

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Robert McIntosh | last post by:
Hi, I'm scripting up a page that will submit a set of data to gateway that returns an XML string. for general example <form name="XMLGATEWAY" method="post"...
3
by: janet | last post by:
hi I want to extract one row from each range data. For example , we had table had following data name age department janet 22 HR John 45 IT Jane 25 IT
0
by: sandeepa | last post by:
Hello all I am using the serial port to receive data(7 bytes per second) from the microcontroller,receiving the data as a string and then splitting the string in two,to display 2 different...
8
by: nospam | last post by:
I have an piece of software that is sending an HTTP POST request to an ASP.Net page. The data posted consists of a chunk of XML data. For some reason (Based on my net research, and my tests at...
1
by: grammy | last post by:
I have a Form with one Subform. After input, I look at the tables, and not all of the info is coming thru.I have looked at the child,master link properties, and they look okay. The main form is a...
1
by: stroumf | last post by:
Hi, Simple question, I want to receive compressed data from a server using AJAX. At the client I make an xmlHttpRequest. Next I want to set the accept-header to Gzip, but I keep getting errors...
0
by: george585 | last post by:
Hello! I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is...
0
by: zelov | last post by:
Hi, I am creating an interface which contains the listbox(C# .net micro framework). When the listbox item is seletected, it will send a character to the serial port and show a "send command"...
1
by: Laszlo Nagy | last post by:
Hi All, I'm using a simple program that uploads a file on a remote ftp server. This is an example (not the whole program): def store(self,hostname,username,password,destdir,srcpath):...
4
by: mayaanu | last post by:
I have developed a GUI based application in C# for communicating with a 16 bit littleendian microcontroller device .the device has a serial port interface. 1.my appplication opens a COM port on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.