473,625 Members | 2,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter Passing from VB .NET to a DLL function (in C++/CLI)

Hello,

I have created a function in C++/CLI which was exported as a .DLL to
be used in VB .NET. I have been having some problems (I think it has
to do with the right syntax) with parameter passing across the
languages. Can somebody help me please. Details are given below:

The function ComputeMedian(x ,y,m_x,m_y) is supposed to have two input
parameters: x, y - both are array of double; and two output
parameters: m_x, m_y - both are just double.

On my C++/CLI side, it is declared as:

double ComputeMedian(a rray<double>^ x, array<double>^ y, double^
median_x, double^ median_y);

where I assign the values as
*median_x = <function returning median of x[]>
*median_y = <function returning median of y[]>

On my VB.NET side, it is called as:

ComputeMedian(t estNumbers, testNumbers, median_x, median_y)

where:
Dim median_x, median_y As New Double
Dim testNumbers() As Double = New Double() {5.0, 3.7, 1.2, 7.6}
The problem is I don't see the values being passed for median_x and
median_y on the VB side. I have debugged the problem and the C++/CLI
program calculates the right values.

Thanks in advance!
Vijay.

Mar 3 '07 #1
1 2459
vijay wrote:
I have created a function in C++/CLI which was exported as a .DLL to
be used in VB .NET. I have been having some problems (I think it has
to do with the right syntax) with parameter passing across the
languages. Can somebody help me please. Details are given below:

The function ComputeMedian(x ,y,m_x,m_y) is supposed to have two input
parameters: x, y - both are array of double; and two output
parameters: m_x, m_y - both are just double.

On my C++/CLI side, it is declared as:

double ComputeMedian(a rray<double>^ x, array<double>^ y, double^
median_x, double^ median_y);

where I assign the values as
*median_x = <function returning median of x[]>
*median_y = <function returning median of y[]>

On my VB.NET side, it is called as:

ComputeMedian(t estNumbers, testNumbers, median_x, median_y)

where:
Dim median_x, median_y As New Double
Dim testNumbers() As Double = New Double() {5.0, 3.7, 1.2, 7.6}

The problem is I don't see the values being passed for median_x and
median_y on the VB side. I have debugged the problem and the C++/CLI
program calculates the right values.
I'm not familiar with the CLR extensions to C++, but here it goes
(take it with a grain of salt):

In your C++ declaration, it seems you're just declaring boxing
reference parameters, and not actual "ByRef" parameters. I ***guess***
the function declaration should be changed to:

double ComputeMedian(a rray<double>^ x, array<double>^ y,
double% median_x, double% median_y);

This declares two "trackable references" (in C++ CLR lingo), which you
must access as simple variables. Therefore, no *median_x or *median_y
syntax:

median_x = <function returning median of x[]>
median_y = <function returning median of y[]>

HTH.

Regards,

Branco.

Mar 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2938
by: PIII450 | last post by:
Hi all, I've got a script using com objects that will work in asp but not work with php. The asp script creates an object that does something and returns a string. I want this sting to be passed to an php script without putting it in a getstring. The getstring will expose the value and thats not my intention. Encryption is an option but I'm not charmed by that solution. I'd rather do it behind the scenes.
6
2246
by: pablo | last post by:
Dear Newsgroupers, The 'main' page contains a call to a function in an included file. This function puts a html-form on the screen. Before the form gets posted (to the 'main' page) some prior errorchecking is done. The form fields are then sent and an object is created (all in the same function). What I need ( imo ) is an array with objects that can be written later to a dbfile to preserve. But I cannot find a solution for the...
0
1530
by: KK | last post by:
Hi MCPP gurus' I have a small problem in parameter passing.This is my situation namespace Abc { public __gc class ClassAbc { public: String* Hello(String* str) {
0
1542
by: Richard Buckshaw | last post by:
Mimick the older C/ pascal dll parameter passing convention? - VB Class Mod? Hello, I have been attempting to write a VB class that would expose its stuff to an older (ok, legacy application) program which can load and call exported functions from the old style dlls. With little documentation to go on, my legacy app defines
4
2053
by: peter | last post by:
I can't get this code to link properly. I got two error during link: error LNK2028: unresolved token (0A00000C) "extern "C" int __stdcall EnumFontFamiliesExW(struct HDC__ *,struct tagLOGFONTW *,int (__stdcall*)(struct tagLOGFONTW const *,struct tagTEXTMETRICW const *,unsigned long,long),long,unsigned long)" (?EnumFontFamiliesExW@@$$J220YGHPAUHDC__@@PAUtagLOGFONTW@@P6GHPBU2@PBUtagTEXTMETRICW@@KJ@ZJK@Z) referenced in function "int...
4
9175
by: Chris | last post by:
Suppose I have the following function signature void foo( Bar &myBar); and I want myBar to be an optional parameter, is there a way to do the logical equivalent of void foo( Bar &myBar = myBar() ) when passing by reference? Every method I've tried gives me syntax
3
1390
by: amadain | last post by:
Help. I'm new to php. I wrote a function that did not seem to work so I checked whether the parameter I was passing to the function was actually being used. I found that it wasn't. When I run the following code I get: Testcheck: and nothing else. It seems that the variable is not being passed to the function. Here is the code:
16
3375
by: Theo R. | last post by:
Hi all, Does the C99 Standard explicitly mention the need for a stack for passing arguments or Is this platform specific? As an example, the ARM9 processor recommends Core Registers R0-R3 be used when passing less than four parameters. However some compilers for ARM9 do not follow this recommendation and place all parameters on the stack. Therefore, the question arises if the compilers were following the C Standard instead.
13
1686
by: frakie | last post by:
Hi 'body, I'm experiencing difficulties on parameter passing. I wrote a library in last months, and now it crashes few times in a month because of errors in parameter passing: using gdb on the core dumps I can see that sometimes in function calls, the caller passes a value and the callee receives another value... Usually it seems to be a shifting on parameters (the callee finds the first value stored in the second argument and so on...)....
0
8182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8688
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...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8352
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
8494
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5570
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();...
1
2614
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
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.