Path: csiph.com!weretis.net!feeder8.news.weretis.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail From: C-Sharp User Newsgroups: alt.comp.lang.vbscript,alt.comp.os.windows-xp,alt.windows7.general Subject: Re: VBScript dictionary delete by index ? Date: Thu, 6 Nov 2025 22:40:40 +0000 Organization: To protect and to server Message-ID: <10ej8cc$273o7$1@paganini.bofh.team> References: <10eho89$10spk$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; Content-Transfer-Encoding: 8bit Injection-Date: Thu, 6 Nov 2025 22:44:28 -0000 (UTC) Injection-Info: paganini.bofh.team; logging-data="2330375"; posting-host="DnCf99zkJilY0+ebjo/XTA.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A"; X-Notice: Filtered by postfilter v. 0.9.3 Content-Language: en Xref: csiph.com alt.comp.lang.vbscript:26 alt.comp.os.windows-xp:8366 On 06/11/2025 09:03, R.Wieser wrote: > Hello all, > > I've got a vbscript Dictionary object, and need to be able to delete a > key-item pair by its index. Can it be done and if so, how is it expressed ? > > Remark: I can use > > oDict.remove oDict.keys()(Index) > > , but that takes two steps and is doing more work than is needed (which also > excludes converting to a pair of arrays and converting it back afterwards by > the way :-) ) > > Regards, > Rudy Wieser > > How about CoPilot method: Dim dict, key Set dict = CreateObject("Scripting.Dictionary") dict.Add "a", "apple" dict.Add "b", "banana" dict.Add "c", "cherry" ' Remove item by index (e.g., index 1) key = dict.Keys()(1) dict.Remove key ' Show remaining items For Each key In dict.Keys     WScript.Echo key & ": " & dict(key) Next > ' Create an array (range of values) > Dim arr > arr = Array(1, 2, 3, 4, 5) > > ' Define the start and end index for reversing > Dim i > Dim reversedArr > ReDim reversedArr(UBound(arr)) ' Create a new array to store the > reversed values > > ' Reverse the array using a loop > For i = 0 To UBound(arr) >     reversedArr(i) = arr(UBound(arr) - i) > Next > > ' Output the reversed array > For i = 0 To UBound(reversedArr) >     WScript.Echo reversedArr(i) > Next