I was trying to code something and I ended writing the code below.
The idea is to get both parts of each entries of the Dictionary.
I set only one entry in the
Music_Disc (below) using the band name and the first names of each members of the band.
I am able to get the Key (
aKey below), but not the Value (
aValue below). I tried with
Music_Dict.Lookup(Search, "Default_Answer"), but I get “Default answer”.
Music_Dict.Value(Search_Variant) leads to
I am out of ideas. Do you have some (the good one, of course) ?
[code] Dim Music_Dict As New Dictionary
Dim aValue As Variant // Computed, I await the name of the band (The Beatles)
Dim aKey As Variant // Computed, I get: John, Paul, George, Ringo
Dim The_Group As Variant // Holds: The Beatles
Dim The_Kids As Variant // Holds: John, Paul, George, Ringo
// Fills the names
The_Kids = “John, Paul, George, Ringo”
The_Group = “The Beatles”
// Add an entry in the Dictionary
Music_Dict.Value(The_Group) = The_Kids
// Get the Key [Contents of The_Kids]
aKey = Music_Dict.Value(The_Group) // Returns: “John, Paul, George, Ringo”: OK *
// Get the Value [Contents of The_Group]
// How do I do that ?
// aValue = I do not know how to code that line to get “The Beatles”[/code]
Passing a string instead of a variant (“The Beatles” instead of
The_Group) returns the same contents: OK.