To achieve this, you need to use the Dictionary object from the Scripting library: -
Dim result : Set result = CreateObject("Scripting.Dictionary") result.Add "Age", 60 result.Add "Name", "Tony"
etc. You can get items as: -
Dim age : age = result("Age")
However, if you have a fixed set of identifiers, you can consider a class definition: -
Class CResult Public Age Public Name End Class Dim result : Set result = new CResult result.Age = 60 result.Name = "Tony" MsgBox "Age: " & result.Age & vbCrLf & _ "Name: " & result.Nname) & vbCrLf
By the way, we usually use CR LF for newlines, not just CR. Also, if you use a method or function as an instruction (as in MsgBox above), do not include parameters in ().
source share