Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Coercing a variant into an array

Folks

I have the following problem

I need to call a function stored into a (third part) DLL that take as
parameter an array of doubles, i.e. it's declaration reads as

Function someFancyFunction(Todays_Date As Date, Data_Array() As
Double) as double

I new to write a "wrapper" VBA function that would be called as a
worksheet function with some parameters being named ranges and that
would eventually call my external, i.e. I'd like to write a formula
like

=SOME.FANCY.WRAPPER(TODAY(),MyNamedRange)

So my question is… how do I do this in an efficient way (an NO, I
can't call directly the DLL in this specific instance) ?

It seems that I have to declare my wrapper as

Public function SOME.FANCY.WRAPPER( prmDate as Date, prmRange as
variant) as double

And as such I will need to parse my variant and build the array by
code…

Is this the way to go or am I missing something obvious ?

Any pointer welcome

Regards

--alexT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Coercing a variant into an array

Alex,

I dont think you'll get it to work unless you create and fill
a true double array

Function MyWrapper(NamedRange As Range) As Double
With NamedRange
Dim r&, c&, dArr#()

ReDim dArr(1 To .Rows.Count, 1 To .Columns.Count)
On Error Resume Next
For r = 1 To .Rows.Count
For c = 1 To .Columns.Count
dArr(r, c) = .Cells(r, c)
Next
Next
End With
MyWrapper = MyFancy(Now, dArr)
End Function


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Alex T wrote :

Folks

I have the following problem

I need to call a function stored into a (third part) DLL that take as
parameter an array of doubles, i.e. it's declaration reads as

Function someFancyFunction(Todays_Date As Date, Data_Array() As
Double) as double

I new to write a "wrapper" VBA function that would be called as a
worksheet function with some parameters being named ranges and that
would eventually call my external, i.e. I'd like to write a formula
like

=SOME.FANCY.WRAPPER(TODAY(),MyNamedRange)

So my question is… how do I do this in an efficient way (an NO, I
can't call directly the DLL in this specific instance) ?

It seems that I have to declare my wrapper as

Public function SOME.FANCY.WRAPPER( prmDate as Date, prmRange as
variant) as double

And as such I will need to parse my variant and build the array by
code…

Is this the way to go or am I missing something obvious ?

Any pointer welcome

Regards

--alexT

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variant Array Steph[_3_] Excel Programming 1 June 2nd 04 01:29 AM
Best way to paste a variant array into a range? AnneB Excel Programming 2 April 28th 04 09:57 PM
basic variant to array conversion Jeff Sward Excel Programming 1 January 26th 04 07:59 PM
Asign Array Variant to Column William C. Smith Excel Programming 3 December 27th 03 04:20 AM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"