By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

Passing array byref to com object

P: n/a
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
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t,
ExistingTolerances)

In VB.NET, the object browser shows the syntax to be:

Public Overridable Sub GetExistingFacetTolerances(ByRef ToleranceCount As
Integer, ByRef ExistingTolerances As System.Array)

Passing the array gives me a Type Mismatch error no matter how I approach
it.

Dim ToleranceCount As Integer
Dim ExistingTolerances() As Single
or
Dim ExistingTolerances() As Double
or
Dim ExistingTolerances() As Object
or
Dim ExistingTolerances As Array = Array.CreateInstance(GetType(Single),
10000)
or Double, Object versions of the above

The following fails with Type Mismatch:

Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t ,
ExistingTolerances)

The requirement to assign a length when using CreateInstance seems rule out
that approach, the method wants an undimensioned array.

Can anyone point out what I'm missing about passing arrays byref to com
objects.

Thanks in advance.
Neil
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Neil,

The answer is mostly on your question that a VB6 long is a VBNet integer.

Cor

"Neil Munro"
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
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t,
ExistingTolerances)

In VB.NET, the object browser shows the syntax to be:

Public Overridable Sub GetExistingFacetTolerances(ByRef ToleranceCount As
Integer, ByRef ExistingTolerances As System.Array)

Passing the array gives me a Type Mismatch error no matter how I approach
it.

Dim ToleranceCount As Integer
Dim ExistingTolerances() As Single
or
Dim ExistingTolerances() As Double
or
Dim ExistingTolerances() As Object
or
Dim ExistingTolerances As Array = Array.CreateInstance(GetType(Single),
10000)
or Double, Object versions of the above

The following fails with Type Mismatch:

Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t ,
ExistingTolerances)

The requirement to assign a length when using CreateInstance seems rule
out
that approach, the method wants an undimensioned array.

Can anyone point out what I'm missing about passing arrays byref to com
objects.

Thanks in advance.
Neil

Nov 21 '05 #2

P: n/a
Correct, and the other argument was declared as an integer in the .NET
version. I don't think that is the problem.

Neil

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Neil,

The answer is mostly on your question that a VB6 long is a VBNet integer.

Cor

"Neil Munro"
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
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t,
ExistingTolerances)

In VB.NET, the object browser shows the syntax to be:

Public Overridable Sub GetExistingFacetTolerances(ByRef ToleranceCount As Integer, ByRef ExistingTolerances As System.Array)

Passing the array gives me a Type Mismatch error no matter how I approach it.

Dim ToleranceCount As Integer
Dim ExistingTolerances() As Single
or
Dim ExistingTolerances() As Double
or
Dim ExistingTolerances() As Object
or
Dim ExistingTolerances As Array = Array.CreateInstance(GetType(Single), 10000)
or Double, Object versions of the above

The following fails with Type Mismatch:

Call oSurfBody.GetExistingFacetTolerances(ToleranceCoun t ,
ExistingTolerances)

The requirement to assign a length when using CreateInstance seems rule
out
that approach, the method wants an undimensioned array.

Can anyone point out what I'm missing about passing arrays byref to com
objects.

Thanks in advance.
Neil


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.