![]() ![]() ![]() This means you can change the object's properties while it is in the collection. Add an object to a VBA collection, the object itself is added, not its value. Here is a solution where Coll("String1") = "myString" does work. Private Sub PrintCollectionContent(ByVal m圜oll As Variant) ' Print out the final status of collection "myStrings" where the obsoleteĭebug.Print "- Collection content after removal of the old content -"ĭebug.Print "- End Collection content after removal of the old content -" ' both the new string and the string to be replaced still in.ĭebug.Print "- End Collection content after adding the new content -" ' Print out the 'in-between' status of collection "myStrings" where we have ![]() MyStrings.Add item:="New Text", Before:=2 ' myStrings will now contain 4 itemsĭebug.Print "- Collection content after adding the new content -" ' Now we want to change "Text 2" into "New Text" ' Or with the "Call" keyword: Call PrintCollectionContent(myStrings)ĭebug.Print "- End Initial collection content -" ' Print out the content of collection "myStrings"ĭebug.Print "- Initial collection content -" Can't you use the Before argument to fulfill this requirement?
0 Comments
Leave a Reply. |