Wednesday, February 13, 2008

Updating Items in Collection

I have been working with collections for sometime now, i had always either deleted or added item in the collection but never updated. Today i had a need to do that, when i searched i couldn't find a direct method to get a item in a collection updated. After some confusing moments i ended up the following code

Dim t As New Collection
Dim iRemove As Integer
Dim iCnt As Integer

iRemove = 3
t.Add ("te")
t.Add ("ew")
t.Add ("Ad")
t.Add ("Adtree")
t.Add ("tewww")
MsgBox t(iRemove)
Call t.Add("Ads", , IIf(iRemove = t.Count, iRemove, iRemove + 1))
For iCnt = 1 To t.Count
Debug.Print t(iCnt)
Next
t.Remove (IIf(iRemove + 1 = t.Count, iRemove + 1, iRemove))
MsgBox t(iRemove)

For iCnt = 1 To t.Count
Debug.Print t(iCnt)
Next


Nothing too fancy in that code, so far it has worked fine but will wait till i implement it in the main code to celebrate ;-) :D. On another note, i have been reviewing UCertify's PrepEngine, I must say it's pretty darn good. Soon, in couple of days, you see a full review of their product in my blog.


Sphere: Related Content