Groups | Search | Server Info | Login | Register
Groups > alt.comp.lang.vbscript > #26
| Path | csiph.com!weretis.net!feeder8.news.weretis.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail |
|---|---|
| From | C-Sharp User <csharp@invalid.invalid> |
| 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> (permalink) |
| 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 |
Cross-posted to 3 groups.
Show key headers only | View raw
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
Back to alt.comp.lang.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar
VBScript dictionary delete by index ? "R.Wieser" <address@is.invalid> - 2025-11-06 10:03 +0100
Re: VBScript dictionary delete by index ? "R.Wieser" <address@is.invalid> - 2025-11-06 15:03 +0100
Re: VBScript dictionary delete by index ? "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-11-06 22:12 +0800
Re: VBScript dictionary delete by index ? solved "R.Wieser" <address@is.invalid> - 2025-11-06 16:09 +0100
Re: VBScript dictionary delete by index ? solved "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-11-08 11:52 +0800
Re: VBScript dictionary delete by index ? solved "R.Wieser" <address@is.invalid> - 2025-11-08 09:07 +0100
Re: VBScript dictionary delete by index ? solved "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2025-11-08 22:55 +0800
Re: VBScript dictionary delete by index ? solved "R.Wieser" <address@is.invalid> - 2025-11-08 16:49 +0100
Re: VBScript dictionary delete by index ? C-Sharp User <csharp@invalid.invalid> - 2025-11-06 22:40 +0000
Re: VBScript dictionary delete by index ? "R.Wieser" <address@is.invalid> - 2025-11-07 09:15 +0100
csiph-web