Results 1 to 26 of 26

Thread: error when item does not exist in collection ! ?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member fabianus's Avatar
    Join Date
    Sep 2004
    Location
    Paris
    Posts
    402

    Resolved error when item does not exist in collection ! ?

    When I search an Item in a collection and the item does not exist I get en error instead of "nothing" !?

    Don't tell me that that's the way it works - this would be just stupid. Or am I doing any mistake? I do

    Dim MyCollection as new collection
    MyCollection.add("something","myIndex")
    MyCollection.Item("xxx")

    This gives an error : The argument 'index' isn't a valid value.

    Thank you for any help!

    Regards,
    Fabian

    What I finally did is to create a function that sends back "nothing" instead of throwing an error...

    VB Code:
    1. Public Function SearchCollectionItem(ByVal Collection As Collection, ByVal Index As String) As Object
    2.         Try
    3.             Return Collection.Item(Index)
    4.         Catch ex As Exception
    5.             Return Nothing
    6.         End Try
    7.     End Function
    Last edited by fabianus; Jul 23rd, 2005 at 01:20 AM.

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