Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to access the last slot of an Array resp Dictionary?

Reply
 
Old 03-17-2009   #1 (permalink)
Thomas Lebrecht


 
 

How to access the last slot of an Array resp Dictionary?

How to I access the last (filed) slot of an Array resp. Dictionary?

Set objLines = CreateObject("Scripting.Dictionary")
Set arrList = CreateObject("System.Collections.ArrayList")

....and then?

Set lastslot = objLines[objLines.num()]

or

Set lastslot = arrList[arrList.last()]

Does not work

Thomas


My System SpecsSystem Spec
Old 03-17-2009   #2 (permalink)
Patrice


 
 

Re: How to access the last slot of an Array resp Dictionary?

Rather than guessing you'll find the doc here :
http://msdn.microsoft.com/en-us/libr...x4(VS.85).aspx (Count)
http://msdn.microsoft.com/en-us/libr...t_members.aspx
(Count) so Count-1 should do the job in both cases...

As a side not it looks like you are using VBScript (?? wiht square brackets
?) but as you rely anyway on .NET being present (it seems you exposed some
..NET types to COM) you might as well just dive and use Visual Basic in its
..NET flavor... (VB EXpress is free).

--
Patrice


"Thomas Lebrecht" <t.lebrecht@xxxxxx> a écrit dans le message de groupe
de discussion : 49bfedb9$0$31339$9b4e6d93@xxxxxx-online.net...
Quote:

> How to I access the last (filed) slot of an Array resp. Dictionary?
>
> Set objLines = CreateObject("Scripting.Dictionary")
> Set arrList = CreateObject("System.Collections.ArrayList")
>
> ...and then?
>
> Set lastslot = objLines[objLines.num()]
>
> or
>
> Set lastslot = arrList[arrList.last()]
>
> Does not work
>
> Thomas
>
My System SpecsSystem Spec
Old 03-17-2009   #3 (permalink)
ekkehard.horner


 
 

Re: How to access the last slot of an Array resp Dictionary?

Thomas Lebrecht schrieb:
Quote:

> How to I access the last (filed) slot of an Array resp. Dictionary?
>
> Set objLines = CreateObject("Scripting.Dictionary")
> Set arrList = CreateObject("System.Collections.ArrayList")
>
> ...and then?
>
> Set lastslot = objLines[objLines.num()]
>
> or
>
> Set lastslot = arrList[arrList.last()]
>
> Does not work
[...]

Dim nMx : nMx = 100
Dim dicX : Set dicX = CreateObject( "Scripting.Dictionary" )
Dim scaX : Set scaX = CreateObject( "System.Collections.ArrayList" )

Dim nIdx
For nIdx = 1 To nMx
dicX( nIdx ) = nIdx
scaX.Add nIdx
Next
If 0 < dicX.Count Then WScript.Echo dicX.Count, dicX( dicX.Keys()( dicX.Count - 1 ) )
If 0 < scaX.Count Then WScript.Echo scaX.Count, scaX( scaX.Count - 1 )
My System SpecsSystem Spec
Old 03-18-2009   #4 (permalink)
Cor Ligthert[MVP]


 
 

Re: How to access the last slot of an Array resp Dictionary?

Thomas,

This is quiet standard, it is forefever count-1 and in true arrays length-1

Cor

"Thomas Lebrecht" <t.lebrecht@xxxxxx> wrote in message
news:49bfedb9$0$31339$9b4e6d93@xxxxxx-online.net...
Quote:

> How to I access the last (filed) slot of an Array resp. Dictionary?
>
> Set objLines = CreateObject("Scripting.Dictionary")
> Set arrList = CreateObject("System.Collections.ArrayList")
>
> ...and then?
>
> Set lastslot = objLines[objLines.num()]
>
> or
>
> Set lastslot = arrList[arrList.last()]
>
> Does not work
>
> Thomas
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to access dictionary to change a word Live Mail
REQ: internetexplorer com object and access to array of links PowerShell
Is a PCI Express X1(not X16) slot faster than a standard PCI slot? Vista General
Randomly access the contents of an array PowerShell
Reading Access Records into an array variable. PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46