Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: GS Newsgroups: microsoft.public.scripting.vbscript Subject: Re: Return a key, value pair from a "for each" loop. Date: Wed, 27 Jan 2016 18:13:01 -0500 Organization: A noiseless patient Spider Lines: 31 Message-ID: References: <56a75878$0$23745$e4fe514c@news.xs4all.nl> <56a89de3$0$23772$e4fe514c@news.xs4all.nl> <56a90ed5$0$23855$e4fe514c@news.xs4all.nl> <56a94543$0$23868$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15"; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 27 Jan 2016 23:10:16 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="385a93d8bbdd6c7b95ff6e6963d18654"; logging-data="11234"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182eltaN9g0miOQMBYdcZ9u" X-Newsreader: MesNews/1.08.06.00-gb X-Face: G"ln~:.wBqHZznO'(lJjjprxGYAjIF7#^u)lx,@"H'F#uXm%j`T6kxat5rq092aW;K*#m4jZ(2aW$34N&B&E@ j~tjGV-aC18j1y>zi.\[ZGXsd Cancel-Lock: sha1:l86QtYS7yI38KkNCKiBj7VgcOZc= X-ICQ: 543516788 Xref: csiph.com microsoft.public.scripting.vbscript:11240 > I think I will either end up with this: > > for i=0 to oRecord.FieldCount-1 > wscript.echo oRecord.GetFieldID(i) &" "& oRecord.GetFieldData(i) > next > > or with this: > > for each oField in oRecord > wscript.echo oField.ID &" "& oField.Data > next > > The latter one looks best but internally costs two extra objects (the > enumerator and the field objects), while the former one does the > same, but > is not as flexible -- a "for each" can easily internally skip records > on the > run if needed (think filtering), a "for" loop needs the full count > upfront, > so no sneaky dropping of certain entries. That's how I see it as well. Your call, of course, depending on what your preference is (or requirement is) for parsing the record data. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion