Article View: adobe.scripting.indesign
Article #17779Re: VB Experts: how to clear a collection?
From: Stu Bloom
Date: Sat, 17 May 2003 01:56
Date: Sat, 17 May 2003 01:56
9 lines
1563 bytes
1563 bytes
That's the simplest, fastest way (with a "Set" in front of savedItems, of course). The compiled C++ code in which the VB kernel is written takes care of all the housekeeping. The other way, a loop:
For i = savedItems.Count to 1 Step -1
savedItems.Remove(i)
Next i
is much slower.
If you're doing a lot with collections, you might want to look into the Scripting Runtime library's Dictionary object. It's much more versatile than the Collection, with a way to check whether an item exists (without resorting to the ugly error trap kludge) and to read the key of an item by index. To access the Scripting Runtime library, add a reference to "Microsoft Scripting Runtime" to your VB project. It's also got some very useful file management objects.
Technical Details
Message-ID:
<1de9286c.0@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de9286c.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,e381395f60723759 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-05-16 19:07:40 PST From: "Stu Bloom" <stu@earlvillepost.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: VB Experts: how to clear a collection? Message-ID: <1de9286c.0@WebX.la2eafNXanI> Date: Fri, 16 May 2003 18:56:10 -0700 References: <1de9286c.-1@WebX.la2eafNXanI> Lines: 17 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit