Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA getting values from a collection?

Tags:

json

excel

vba

vb6

I am very new to VBA and I can not figure out how to get values from a Collection.

This is my code:

Dim p As Object
Set p = JSON.parse(Response.Content)

Dim links As Object
Set links = p.Item("links")

In the debugger for "links" I see:

enter image description here

I am using this library to parse json : http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html

The part I have in json is:

"links":[
    {
        "rel":"next",
        "href":"www.google.com"
    }
]

How can I get the value of "rel" here?

like image 570
Koray Tugay Avatar asked Mar 19 '23 07:03

Koray Tugay


1 Answers

Don't forget the bang operator, designed for collection access by key:

links(1)!rel

or:

links(1)![rel] 'When there are spaces or reserved words.
like image 91
Bob77 Avatar answered Mar 29 '23 20:03

Bob77