Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get keys from dictionary?

Status
Not open for further replies.

tektipwfkm

Programmer
Nov 18, 2008
2
CN
Dim dic As Object
Dim keyColl As Object

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "a", "1"
dic.Add "b", "2"
dic.Add "c", "3"

keyColl = dic.Keys ' Prompt "Object method returned an unsupported data type"

How to get keys collection from dictionary?

 
Hi,

You should have looked further in HELP...
Code:
Dim dic As Object
Dim keyColl, i

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "a", "1"
dic.Add "b", "2"
dic.Add "c", "3"

keyColl = dic.Keys  

For i = 0 To dic.Count -1 
    Print keyColl(i)         
Next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for your help!

But in AttachMate Extra! Macro Editor V6.7, it can not run correctly.


' *********************************
Dim dic As Object
Dim keyColl, i

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "a", "1"
dic.Add "b", "2"
dic.Add "c", "3"

keyColl = dic.Keys

For i = 0 To dic.Count -1
Print keyColl(i) ' Prompt "Unknow array of function: keycoll"
Next

' *********************************

Dim dic As Object
Dim keyColl, i

Set dic = CreateObject("Scripting.Dictionary")

dic.Add "a", "1"
dic.Add "b", "2"
dic.Add "c", "3"

keyColl = dic.Keys 'Prompt "Object method returned an unsupported data type"

For i = 0 To dic.Count -1
'Print keyColl(i) 'Remark this line
Next

 
Guess you'll have to code in Excel VBA and reference Extra.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top