473,614 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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.c pp", 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 1842

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

Similar topics

0
2299
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" action="http://tothexmlgateway.com/xmldata.cfm"> <input type="hidden" name="username" value="username">
3
1400
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
1223
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 values.Am using the Oncomm event to detect reception of data.All was working fine till recently. I then changed my controller program to send 7 bytes/10msec.The rest of the settings are same(9600 baud rate). However now,after a few cycles of receiving...
8
3861
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 least) .Net does not like getting XML data as HTTP POST. If I call Request.SaveAs(...) to save a copy of the request to examine, it doesn't match the request sent (verified my monitoring network traffic). I suspect some filtering is occurring...
1
1603
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 contract, showing prices, etc. The subform is the order, only shows shipped info, not dollars. In the subform table it has the shipped data and price fields, but the price fields are not getting filled in, yet they have been input on the main form. What...
1
5900
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 on that under opera. At server-side I first check the accept-header, if it supports gzip I make a ZIP-stream and set the content-encoding to gzip. Normaly I would think the browser itself can handle it and give the uncompressed response.
0
3566
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 supposed to do the following: monitor ALL INCOMING TCP traffic on the local computer, and save certain parts of it as files - not log files though, but actual files that are sent to the computer as part of http or ftp. Basically if a user browse a page...
0
3934
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" screen. When receiving the data from serial port, it will show another "receive command" screen. The problem i am facing now is the program not able to show out the "receive command" screen. The following is some part of the code: public class...
1
4113
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): self.ftp = ftplib.FTP(hostname) self.ftp.login(username,password) self.ftp.set_pasv(False)
4
13375
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 which the device is connected with proper settings for the device. 2.It writes a command to the port. 3.datareceived event of the serial port reads the data in to a byte array. 3.i have closed the serialport using close() method The problem that i...
0
8621
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6087
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4049
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4119
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1712
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.