Multiple strings in multidimensional array vbscript

后端 未结 3 1210
面向向阳花
面向向阳花 2021-01-06 13:18

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. N

3条回答
  •  攒了一身酷
    2021-01-06 13:38

    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]

    Dates = Split("12.02.2016, 13.08.2017, 19.05.2018", ", ")
    Temperatures = Split("23.1, 24.9, 75.3", ", ")
    Humidity = Split("26, 29, 95", ", ")
    
    Dim AmbientConditionsArray()
    ReDim AmbientConditionsArray(2,UBound(Dates))
    For i = 0 TO UBound(Dates)
        AmbientConditionsArray(0,I) = Dates(I)
        AmbientConditionsArray(0,I) = Temperatures(I)
        AmbientConditionsArray(0,I) = Humidity(I)
    Next
    

    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]

    Dates = Split("12.02.2016, 13.08.2017, 19.05.2018", ", ")
    Temperatures = Split("23.1, 24.9, 75.3", ", ")
    Humidity = Split("26, 29, 95", ", ")
    
    Dim AmbientConditions
    
    AmbientConditions = Array(Dates, Temperatures, Humidity)
    
    For I = 0 To UBound(Dates)
        Debug.Print AmbientConditions(0)(I), AmbientConditions(1)(I), AmbientConditions(2)(I)
    Next
    

提交回复
热议问题