Multiple strings in multidimensional array vbscript

后端 未结 3 1208
面向向阳花
面向向阳花 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:47

    While you can use a multidimensional array, it will be comparatively cumbersome.

    How about simply using three separate regular arrays?

    Dates = Split("12.02.2016, 13.08.2017, 19.05.2018", ", ")
    Temperatures = Split("23.1, 24.9, 75.3", ", ")
    Humidity = Split("26, 29, 95", ", ")
    

    to work with them as a block of values I would use a dictionary.

    Dim AmbientConditions
    Set AmbientConditions = CreateObject("Scripting.Dictionary")
    
    AmbientConditions.Add "Dates", Split("12.02.2016, 13.08.2017, 19.05.2018", ", ")
    AmbientConditions.Add "Temperatures", Split("23.1, 24.9, 75.3", ", ")
    AmbientConditions.Add "Humidity", Split("26, 29, 95", ", ")
    

    Later you can access individual values in a readable manner:

    MsgBox AmbientConditions("Humidity")(1)
    ' -> shows "29"
    

提交回复
热议问题