Consulting

Results 1 to 3 of 3

Thread: Array as a parameter

  1. #1
    VBAX Newbie
    Joined
    May 2007
    Posts
    1
    Location

    Array as a parameter

    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?

  2. #2
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Quote Originally Posted by iftg
    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

  3. #3
    Well... A variant can hold anything including an array of variants...

    [VBA]
    Sub Caller()
    Dim Dbl(1) As Double
    MyMethod Dbl
    End Sub

    Sub MyMethod(A As Variant)

    End Sub
    [/VBA]

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

    [VBA]
    Sub Caller()
    Dim Dbl(1) As Double
    MyMethod Dbl
    End Sub

    Sub MyMethod(ParamArray MyArray())

    End Sub
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •