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

passing double arrays from vb to a c dll using a type lib

Hi,

[I posted this on comp.lang.basic.visual.misc, but nobody answered to
it, so I figured this would be a more c-related question. Maybe you can
help...]

I wrote a c dll with a type library to use it in vb. No problem,
everything works fine.

Now I needed to pass an array of type double to the dll. I defined the
function in the type library like this:
double VBEXPORT aigIGApproximation([in] double intervalCount,
[in] SAFEARRAY(double) lambda_i,
[in] SAFEARRAY(double) alpha_i[], [in] double iMax,
[out] double* gammaValue);
with
#define VBEXPORT __declspec( dllexport ) __stdcall

In the object browser (in VB IDE) this function is shown as this:
Function aigIGApproximation(intervalCount As Double,
lambda_i() As Double, alpha_i() As Double,
iMax As Double, gammaValue As Double) As Double

That /looks/ good, but doesn't work. VB says I would use a incompatible
parameter type.

What am I doing wrong? How do I have to declare the type lib to make the
dll accept my double array within VB?

Any hints?

Sascha

Nov 13 '05 #1
3 3301

"Sascha Herpers" <fo***********@brainpowered.de> schrieb im Newsbeitrag
news:bo*************@ID-144102.news.uni-berlin.de...
Hi,

[I posted this on comp.lang.basic.visual.misc, but nobody answered to
it, so I figured this would be a more c-related question. Maybe you can
help...]


Sorry, it isn't
[OT]pass the first elem of the array ByRef maybe[/OT]

snip

Robert
Nov 13 '05 #2
Sascha Herpers <fo***********@brainpowered.de> wrote:
[I posted this on comp.lang.basic.visual.misc, but nobody answered to
it, so I figured this would be a more c-related question.
It isn't. It _may_ be a M$-Visual-C++-4.984.288a-for-M$-Windows-XP
question, but it isn't C.
I wrote a c dll with a type library to use it in vb. No problem,
everything works fine.

Now I needed to pass an array of type double to the dll. I defined the
function in the type library like this:
(That's a declaration, btw, not a definition.)
double VBEXPORT aigIGApproximation
This isn't C, unless you've #defined VBEXPORT or aigIGApproximation to
be something legal (e.g., the word static, or just whitespace).
([in] double intervalCount, ^^^^

This is a syntax error in C. Ditto for all the other parameters, and for
[out].
[in] SAFEARRAY(double) lambda_i, ^^^^^^^^^^^^^^^^^
This isn't C, either, unless you've #defined SAFEARRAY to something
sensible.
[in] SAFEARRAY(double) alpha_i[], [in] double iMax,
[out] double* gammaValue);
with
#define VBEXPORT __declspec( dllexport ) __stdcall
Ah, I see (I hope you didn't put the #define after the function
declaration in your code as well - that wouldn't work). Well, _that_
isn't C, either. Again, it may be VC++-WinXP, but it isn't ISO C, and we
can't guarantee that it isn't the source of your problems.
In the object browser (in VB IDE) this function is shown as this:
Function aigIGApproximation(intervalCount As Double,
lambda_i() As Double, alpha_i() As Double,
iMax As Double, gammaValue As Double) As Double

That /looks/ good, but doesn't work. VB says I would use a incompatible
parameter type.


Since I can't even work out what the type for the C function is supposed
to be, and the type for the VB function is off-topic here, I couldn't
possibly comment. But a VC-specific group just might.

Richard
Nov 13 '05 #3
On Wed, 12 Nov 2003 07:26:46 +0100, in comp.lang.c , Sascha Herpers
<fo***********@brainpowered.de> wrote:
Hi,

[I posted this on comp.lang.basic.visual.misc, but nobody answered to
it, so I figured this would be a more c-related question.


Its not.

You probably need to read the MSDN online tutorials on passing arrays
between VC and VB. They're actually quite good. As I recall, the bit
you're missing is byref or byval in the VB declaration, one or the
other. But do read the tutorials.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
Nov 13 '05 #4

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

Similar topics

5
by: harry | last post by:
I have 2 multi-dim arrays double subTotals = null; String rowTitles = null; I want to pass them to a function that initialises & populates them like so - loadData( rowTitles, subTotals);
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
3
by: Marco | last post by:
Hello there, We're new to C# and have noticed a strange behaviour which we don't yet understand. We wrote a COM DLL (in VC++ 6.0) which performs some calculation based on some double arrays...
0
by: volx | last post by:
Hello all: What is the proper way to implement in MC++ a web service which accepts a multi dimensional array as a parameter to one of its methods? This does compile: double...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
2
by: Neil Munro | last post by:
I'm having some "type" difficulty in passing a .NET array (byref) to a COM based API (Autodesk Inventor). In VB6 the code to return an array of tolerance values is: Dim ToleranceCount As Long...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.