|
-
Jul 7th, 2000, 03:27 AM
#1
Thread Starter
Junior Member
Hi All,
Does anyone know an easy way to merge two collections in vb.
i tried the following code
Private Sub cmdMerge_Click()
Private col1 As New Collection
Private col2 As New Collection
Private col3 As New Collection
col1.Add "1", "1"
col2.Add "2", "2"
col3 = col1 + col2
End Sub
and it flopped!
Any suggestions pl? Thanx in advance
okdk
-
Jul 7th, 2000, 03:37 AM
#2
Frenzied Member
try this,
Code:
Public Function MergeCollections(Coll1 As Collection, Coll2 As Collection) As Collection
Dim retval As New Collection
Dim varTemp As Variant
For Each varTemp In Coll1
retval.Add varTemp
Next varTemp
For Each varTemp In Coll2
retval.Add varTemp
Next varTemp
Set MergeCollections = retval
End Function
it won't do the keys though, I'm not sure if that's possible, I can't seem to find a way of getting at the keys.
-
Jul 7th, 2000, 03:42 AM
#3
Thread Starter
Junior Member
Hmm...I actually want to avoid the for loops and any other loops...that will be the final resort.
-
Jul 7th, 2000, 04:08 AM
#4
Thread Starter
Junior Member
thanks but solved my problem
hi! all
anyways thanx for the thinking...but i got a solution to my problem...unfortunately since the details are a lil project specific...i am unable to share the solution with all of u...
thanx anyways
okdk
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|