Подтвердить что ты не робот

Каков наилучший тип данных VBA`key` => `value` для сохранения данных так же, как и массив PHP

Я работаю с VBA и должен сохранять данные в типе key = > value для достижения максимальной скорости; Этот тип данных помогает мне кэшировать ответный текст из запроса http, увеличивает скорость запроса. Но я не знаю, что это лучший способ сделать это? Мне нужен тип данных, такой же, как php-массив с key=>value! Спасибо за помощь!

4b9b3361

Ответ 1

Вы смотрели на объект словаря?

Он доступен как часть среды выполнения сценариев Microsoft. Четкий пример того, как добавить это, дан этим SO ответом.

Sub DictExample1()

Dim dict As Dictionary
Dim v As Variant

    'Create the dictionary          
    Set dict = New Dictionary

   'Add some (key, value) pairs
    dict.Add "John", 34
    dict.Add "Jane", 42
    dict.Add "Ted", 402

    'How many items do we have?
    Debug.Print "Number of items stored: " & dict.Count

    'We can retrieve an item based on the key
    Debug.Print "Ted is " & dict.Item("Ted") & " years old"


   'We can test whether an item exists
    Debug.Print "We have Jane age: " & dict.Exists("Jane")
    Debug.Print "We have Zak age " & dict.Exists("Zak")

    'We can update a value by replacing it
   dict.Item("Ted") = dict.Item("Ted") / 10

    Debug.Print "Ted real age is: " & dict.Item("Ted")

   'We can add more items
    dict.Add "Carla", 23

   'And we can iterate through the complete dictionary
    For Each v In dict.Keys
        Debug.Print "Name: " & v & "Age: "; dict.Item(v)
    Next

End Sub

(Источник: http://www.techbookreport.com/tutorials/vba_dictionary.html)