I am working on a program which performs calculations on several physical elements. There are about 5 types of elements, each requiring different inputs(with different datatypes) to calculations. There is no limit on the number of elements or order in which they can be calculated.
For example: the first set of data might have an element of type A, and element of type B and a second element of type A.
The second set of data might have an element of type C, an element of type B, and five elements of type A.
Element type A might have a type(string) input and a pressure(double) input. Element type B might have a type(string) input, a length(double) input, number of fins(integer) input. Element type C might have a length(double) input, diameter(double) input and quantity(integer) input
Since I don't know the number or type of elements ahead of time, I have been using a variant array which has a number of rows which can be assigned after elements are selected by the user, and a number of columns equal to the maximum number of data points needed by any element.
The problem is that when I then try to use that data in other functions (by calling Array(1,2)) I get a "byref argument type mismatch" error.
From what I can tell, this means that my program doesn't KNOW that the value contained in the slot of my array can/should be the correct datatype. it just sees "variant" as opposed to "double" or "string" and throws an error.
I have found a couple ways around this. 1)I can put the data in parenthesis when I call the function. Apparent this forces the data to conform to the expected datatype. function(input1, (Array(1,2)), input3)
2) I can go into all my functions and change the expected data-types to variant.
The problem is I am performing an engineering calculation, and I care about maintaining a certain level of accuracy in my numbers. I also DON'T really want my functions to be able to run if the inputs don't make sense. It seems to me that option 1 carries a high risk of loosing important data during the forced conversion. I'm not sure that option 2 is any better, since vba doesn't seem to assign/track these datatypes like I was imagining it did.
Is there any better way for me to assign and transfer data of a variety of types?