![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||