H
Hills
Hi, I really can't know it myself how to know a key that has already been
added in a collection, and vise versa, that a key is not in the collection.
Here is my code in a form
'=========================================================
Public orderCollection As New Collection
'=========================================================
Private Sub test(orderID As Integer)
Dim order As New Form_Order
'here I want to add code to see if Cstr(orderID) is already
'a key in the collection. But I don't know how to do it.
orderCollection.Add order, Cstr(orderID)
order.visible = true
End Sub
I want to use orderCollection to keep each instance of the order form with
it's orderID as a key. So a multiple instance of order form can be opened.
When it is closed, it's quite simple to use collection.remove method to
remove a key, and add a key is simple too.
But I don't know how to make sure that a key has already been added to the
collection or a key is not added.
So far the only way I found is to add the key anyway, and catch the "key
already in collection" error and set the order to nothing if adding a
duplicated key.
Any better ideas?
TIA.
added in a collection, and vise versa, that a key is not in the collection.
Here is my code in a form
'=========================================================
Public orderCollection As New Collection
'=========================================================
Private Sub test(orderID As Integer)
Dim order As New Form_Order
'here I want to add code to see if Cstr(orderID) is already
'a key in the collection. But I don't know how to do it.
orderCollection.Add order, Cstr(orderID)
order.visible = true
End Sub
I want to use orderCollection to keep each instance of the order form with
it's orderID as a key. So a multiple instance of order form can be opened.
When it is closed, it's quite simple to use collection.remove method to
remove a key, and add a key is simple too.
But I don't know how to make sure that a key has already been added to the
collection or a key is not added.
So far the only way I found is to add the key anyway, and catch the "key
already in collection" error and set the order to nothing if adding a
duplicated key.
Any better ideas?
TIA.