ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on Dictionary datatype?? (https://www.excelbanter.com/excel-programming/381433-help-dictionary-datatype.html)

[email protected]

Help on Dictionary datatype??
 
Hi,

fairly straight forward one here.

Can I create a nested Dictionary structure, that is, store and retrieve
Objects of type Dictionary within another Object of type Dictionary??

Also, I would be greatfull if someone could tell me where on MSDN i can
find this sort of information. All I am able to find is overly simple
examples using primitive data types, what I am looking for is a full
API documentation similar to that which Sun provide for the Java
programming language.

Many thanks in advance!

Alan


Chip Pearson

Help on Dictionary datatype??
 
The following may get you started.


Dim MDict As Dictionary
Dim SubDict1 As Dictionary
Dim SubDict2 As Dictionary

Set MDict = New Scripting.Dictionary
Set SubDict1 = New Scripting.Dictionary
Set SubDict2 = New Scripting.Dictionary

SubDict1.Add Key:="A", Item:=1
SubDict1.Add Key:="B", Item:=2
SubDict2.Add Key:="X", Item:=88
SubDict2.Add Key:="Y", Item:=99
MDict.Add Key:="SubDict1", Item:=SubDict1
MDict.Add Key:="SubDict2", Item:=SubDict2

MDict.Item("SubDict1").Add Key:="Nest1", Item:=3
MDict.Item("SubDict1").Add Key:="Nest2", Item:=4

Debug.Print MDict.Item("SubDict2").Item("X")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

wrote in message
ups.com...
Hi,

fairly straight forward one here.

Can I create a nested Dictionary structure, that is, store and retrieve
Objects of type Dictionary within another Object of type Dictionary??

Also, I would be greatfull if someone could tell me where on MSDN i can
find this sort of information. All I am able to find is overly simple
examples using primitive data types, what I am looking for is a full
API documentation similar to that which Sun provide for the Java
programming language.

Many thanks in advance!

Alan




[email protected]

Help on Dictionary datatype??
 
This appears to work perfectly!

many thanks.

A

Chip Pearson wrote:
The following may get you started.


Dim MDict As Dictionary
Dim SubDict1 As Dictionary
Dim SubDict2 As Dictionary

Set MDict = New Scripting.Dictionary
Set SubDict1 = New Scripting.Dictionary
Set SubDict2 = New Scripting.Dictionary

SubDict1.Add Key:="A", Item:=1
SubDict1.Add Key:="B", Item:=2
SubDict2.Add Key:="X", Item:=88
SubDict2.Add Key:="Y", Item:=99
MDict.Add Key:="SubDict1", Item:=SubDict1
MDict.Add Key:="SubDict2", Item:=SubDict2

MDict.Item("SubDict1").Add Key:="Nest1", Item:=3
MDict.Item("SubDict1").Add Key:="Nest2", Item:=4

Debug.Print MDict.Item("SubDict2").Item("X")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

wrote in message
ups.com...
Hi,

fairly straight forward one here.

Can I create a nested Dictionary structure, that is, store and retrieve
Objects of type Dictionary within another Object of type Dictionary??

Also, I would be greatfull if someone could tell me where on MSDN i can
find this sort of information. All I am able to find is overly simple
examples using primitive data types, what I am looking for is a full
API documentation similar to that which Sun provide for the Java
programming language.

Many thanks in advance!

Alan




All times are GMT +1. The time now is 09:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com