Results 1 to 4 of 4

Thread: Collections help please

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Unhappy

    adding collections.
    i have added a collection to my project in a class module
    but i get errors when trying to run it
    what am i doing wrong help me please???

    Code:
    Private colDetails As New collection
    'then using a function
     colDetails.add newDetail, CStr(.id)
    'and i get a runtime error '457'
    'the key is already associated with an element of this 
    'collection any ideas what that means????

  2. #2
    Guest
    Can you give more detail. What is newDetail and .id

  3. #3
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    collection's index is already being used

    Look at the syntax def for the add method in collections. The index field must be unique. You're adding an existing index.
    end war
    stop greed

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    You already have an item ...

    Whatever is the value of the CStr(.ID) has already been used with some other item, I think. The index of the item to be added has to be unique.

    If this is the problem, try to add elements with a unique index, or try to generate an index whenever an item is added to the collection.

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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