CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Posts
    1

    NEED HELP!!! Iterating thru embedded dictionaries

    I'm porting a VB6 app to .NET, but encountering problems iterating through ALL of my embedded dictionaries:

    ------VB6 code------:
    dim dctOne as new Scripting.Dictionary
    dim vOne as Variant
    dim vTwo as Variant

    'dctOne has Key=unique number, Value=Dictionary
    For each vOne in dctOne

    'Loop through embeded dictionary related to dctOne's
    'current key
    For each vTwo in dctOne(vOne)
    ...........

    -------.NET code-----:
    dim dctOne as _
    new System.Collections.Specialized.HybridDictionary
    dim deDictEntryOne as System.Collections.DictioaryEntry
    dim deDictEntryTwo as System.Collections.DictioaryEntry

    'dctOne has Key=unique number, Value=Dictionary
    For each deDictEntryOne in dctOne

    'Loop through embeded dictionary related to dctOne's
    'current key
    For each deDictEntryTwo in dctOne(cstr(deDictEntryOne.key))


    --------The .NET code on the last line doesn't compile: "Expression is of type 'System.Object', which is not a collection type." SOOOO I'm not sure what is the correct way to do this in .NET.

    I don't want to use object data types at all, and NEED to find the correct way to iterate through MANY LEVELS of a dictionary in .NET. It may be that I cannot use DictionaryEntry structure, but I CAN'T FIND DOCUMENTATION ANYWHERE.

    I REALLY NEED AND WOULD REALLY APRECIATE ANY KIND OF ADVICE!!!!!!!!!!!!!

    THANKS IN ADVANCE

  2. #2
    Join Date
    Oct 2002
    Location
    Houston
    Posts
    6
    Would something such as this work for you?

    Dim dctOne As New System.Collections.ArrayList()
    Dim deDictEntryOne As System.Collections.Hashtable()

    For Each deDictEntryOne In dctOne

    Next

    'or

    Dim dctOne1 As New System.Collections.Specialized.HybridDictionary()
    Dim deDictEntryOne1 As System.Collections.IDictionaryEnumerator

    deDictEntryOne1 = dctOne1.GetEnumerator()

    While deDictEntryOne1.MoveNext()
    'deDictEntryOne1.Current gets you the current object.
    End While
    Mike Huguet
    Senior Consultant
    Software Architects, Inc.
    MCSD, MCDBA, MCSA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured