Array as a parameter

vba Russia
  • 13 years ago

    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?

  • 13 years ago

    Without seeing your code it's hard to give you a precise answer, but I guess you tried to pass the double array as the parameter when calling the procedure.  The type-mismatch error in that case is caused by the fact that the procedure expects an array of the Variant type, and therefore "doesn't like" the fact that you try to pass it an array of the Double-type.

    I can think of 2 options:

    1. Use the Double-type as the parameter in the procedure-definition.

    2. In your calling procedure, create an array of the Variant-type, fill it with the data from the Double-array, and then pass it on to your procedure.

    Hope this helps.


Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”