PDA

View Full Version : Array as a parameter



iftg
05-04-2007, 10:27 PM
I need to write a procedure that would take an array of variants as a parameter. However, the data I need to work with in the calling procedure must be stored in an array of doubles.
When I do it directly I get an error "Type mismatch". What could you suggest please?

stanl
05-05-2007, 06:53 AM
IWhat could you suggest please?

Offhand I could suggest...

You specifying a procedure for what?

But I believe, based on what you have said, using an array pointer and CopyMemory() might assist. .02 Stan

tstom
05-10-2007, 03:32 PM
Well... A variant can hold anything including an array of variants...


Sub Caller()
Dim Dbl(1) As Double
MyMethod Dbl
End Sub

Sub MyMethod(A As Variant)

End Sub


See ParamArray as well which will cast an array of doubles into a variant array...


Sub Caller()
Dim Dbl(1) As Double
MyMethod Dbl
End Sub

Sub MyMethod(ParamArray MyArray())

End Sub