H
Hills
Hi,
I use orderCollection to keep these opened instances of the order form
with it's orderID as a key. So multiple instances of one single order
form can be opened simultaniously. When one order form is closed, it's
quite simple to use collection's remove method to remove a key, and
after an order opens, add a key is simple too.
But I don't know if there is way to ensure that a key has already been
added to the collection or a key is not added into. I use some like:
If IsNull(orderCollection(Cstr(orderID)).Name) ..
If Not IsObject(orderCollection(Cstr(orderID)) ...etc. no luck.
So far the only way I found is to add the key anyway, without any
additional code, and catch the "key already in collection" error and
set the order to nothing if adding a duplicated key.
Any better ideas?
TIA.
I use orderCollection to keep these opened instances of the order form
with it's orderID as a key. So multiple instances of one single order
form can be opened simultaniously. When one order form is closed, it's
quite simple to use collection's remove method to remove a key, and
after an order opens, add a key is simple too.
'=============================================
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
But I don't know if there is way to ensure that a key has already been
added to the collection or a key is not added into. I use some like:
If IsNull(orderCollection(Cstr(orderID)).Name) ..
If Not IsObject(orderCollection(Cstr(orderID)) ...etc. no luck.
So far the only way I found is to add the key anyway, without any
additional code, and catch the "key already in collection" error and
set the order to nothing if adding a duplicated key.
Any better ideas?
TIA.