I am trying to add multiple strings into a multidimensional array in VBScript. I hope I can explain it in a short way: Every string contains some data separated by commas. Now I would like to add all these data into an array, one dimension for every string.
For example
Dates = "12.02.2016, 13.08.2017, 19.05.2018"
Temperatures = "23.1, 24.9, 75.3"
Humidity = "26, 29, 95"
It is no Problem to get every String into an one dimensional array by using
AmbientConditionsArray = Split(Dates, ", ")
But I really have no idea to get it into a two dimensional array like
AmbientConditionsArray(0,0) = Date1
AmbientConditionsArray(0,1) = Temperature1
AmbientConditionsArray(0,2) = Humidity1
AmbientConditionsArray(1,0) = Date2
AmbientConditionsArray(1,1) = Temperature2
AmbientConditionsArray(1,2) = Humidity2
and so on.
@Tomalak's answer is a neat way of doing it but in case you did want a native Multi-Dimensional Array approach closer to your original request you would use a Dynamic Array, like this.
Output:
Also followed @Tomalak's suggestion to use Named Constants for the various dimensions.
While you can use a multidimensional array, it will be comparatively cumbersome.
How about simply using three separate regular arrays?
to work with them as a block of values I would use a dictionary.
Later you can access individual values in a readable manner:
Taking form your code here is what could be done; this is a true multi-dimensional array. [Code was edited due to slight oversight on my part]
Now all your data is neatly stored in a single multi-dimensional array.
This second model is close to the first answer, but I think it meets your stated need as well. [It uses nested arrays to meet the objective of a hybrid multi-dimensional array]