473,320 Members | 1,883 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,320 software developers and data experts.

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(array<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(testNumbers, 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 2415
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(array<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(testNumbers, 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(array<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
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...
6
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...
0
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
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)...
4
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...
4
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 =...
3
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...
16
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...
13
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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...
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.