Results 1 to 2 of 2

Thread: Collections question (newbie)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Nashville, TN
    Posts
    54
    I have a collection call colors. I have about 15 color elements in this collection.

    When I'm adding colors to the collection is there away to see if one of them already exist. For example lets say element #3 is blue, but at 16 the user wants to add blue again, how could I test to see if its already there
    Thanks

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    You can modify this:

    Dim sDummy As String
    Dim bFound As Boolean
    On Error Resume Next
    'If the text is in the collection, Err = 0, otherwise it's not
    sDummy = MyCollection.Item(Text1.Text)
    bFound = (Err = 0)
    If bFound Then
    Err.Clear
    MsgBox "Already in list"
    Else
    List1.AddItem Text1.Text
    MyCollection.Add Text1.Text, Text1.Text
    End If


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