473,405 Members | 2,187 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,405 software developers and data experts.

Passing Structures from C++ to a VB .NET DLL

2
I'm having trouble getting the correct syntax for passing a structure from C++ to VB .NET.

I have a VB .Net DLL program with the following code:
Expand|Select|Wrap|Line Numbers
  1.     Public Structure testParams
  2.         Public iFirst As Integer
  3.         Public iSecond As Integer
  4.     End Structure
  5.  
  6.     Public Class clsKpdUI
  7.         Public Function ShowForm(ByVal Param1 As testParams) As Integer
  8.             ' Code
  9.         End Function
  10.     End Class
  11.  
I have C++ program with the following code:
Expand|Select|Wrap|Line Numbers
  1.     struct testParams {
  2.         int iFirst;
  3.         int iSecond;
  4.     };
  5.  
  6.     kpdUI::clsKpdUI myUI;
  7.     testParams tp;
  8.     tp.iFirst = 4;
  9.     tp.iSecond = 3;
  10.     myintR = myUI.ShowForm3(tp);
  11.  
When I try to compile the C++ code, I get the following Error:
Error 1 error C2664: 'kpdUI::clsKpdUI::ShowForm' : cannot convert parameter 1 from 'testParams' to 'kpdUI::testParams' c:\test\Form1.h 133 TestKpdUIcpp

How do I correct this error?

Thank,
Gary
Feb 12 '10 #1
2 2334
weaknessforcats
9,208 Expert Mod 8TB
You might read up in MSDN about VB/C++ interoperability. There is sample code there for how to do this.
Feb 13 '10 #2
gstarr
2
Thanks for the response. Someone else pointed out what I was doing wrong. Turns out that I need to reference the Structure that is defined in VB when I'm declaring the variable in C++

instead of this in C++
testParams tp;
I needed to do this:
kpdUI::testParams tp;

Now it works like a champ.

Thanks again... Gary
Feb 13 '10 #3

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

Similar topics

2
by: jason | last post by:
Hello everyone, I have a C# object library which encapsulates data. Data is keyed by way of Guid values, which are stored in the objects as read-only Guid properties. However, we have a...
4
by: dogalacar | last post by:
Hi All, I am trying to pass array of structures from a C dll to C# as msdn sample does(outarrayofstructs sample) but PtrToStructure function gives error : --> "structure must not be a value...
8
by: Bryan G | last post by:
Hi, I'm working on a VB project which involves using C library functions which take struct pointers as args, and I keep running into this error when trying to pass either an IntPtr or a Structure...
2
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short...
3
by: Steve | last post by:
Hello, I created a public Structure in a Standard Module and also an array of Structures. Then I load data into the array of structures in a public sub that I call on the Form load event. ...
3
by: Christopher H | last post by:
I've been reading about how C# passes ArrayLists as reference and Structs as value, but I still can't get my program to work like I want it to. Simple example: ...
13
by: ElderGeek | last post by:
Hello. I'm pretty new to C, and having a problem which I suspect this has to do with how I'm handling (or not handling) pointers. I have an array of dirent structures which I am passing to a...
7
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
13
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been supplied as a .LIB file and a .h header file. I have got most of the functions to work but am really struggling with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.