WIN10 Collection Issues

Started by stanl, December 09, 2018, 08:16:46 AM

Previous topic - Next topic

stanl

My Win10 has Office 2019 and Visual Studio 2017 Community [updated], and I assume I have the same collection objects as with Win 7.  The following now gives an invalid COM Object


Code (WINBATCH[font=verdana) Select
]
d = CreateObject("VBA.Collection")
d.Add( "Athens" )
d.Add( "Belgrade" )
d.Add( "Cairo" )


[/font]But I can initialize

Code (WINBATCH) Select


d = CreateObject("Scripting.Dictionary")
d.Add( "a", "Athens" )
d.Add( "b", "Belgrade" )
d.Add( "c", "Cairo" )
Which errors with k = d.Keys(i) is NOT a Collection

Code (WINBATCH) Select

For i= 0 to (n - 1)
   k = d.Keys(i)
   t = d.items(i)
   message( "Item %t%","key %k%")
Next
[code]


Basically just checking on a few script snippets that worked in Win 7 using COM Objects.[/size][/font]


stanl

I hate stumbling on something that works after posting... this worked.


Code (WINBATCH) Select


ForEach k in d.Keys
   message(k,d.item(k))
Next

td

Or

Code (winbatch) Select
a = d.keys()
for i = 0 to d.count - 1
   k = a[i]
next
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Thanks. I'm really more interested in not being able to initialize vba.collection - it exists in my Excel 2019 Object Inspector and the references are correct, but even using it in an excel macro I get the 429 error. My AccessDatabase Engine is for 2016, I had 2010 but had issues scripting with the ACE.OLEDB provider. There is also a Microsoft.VisualBasic.Collection which may work with WB and the CLR.  Basic rock and hard place - While I prefer a strict WB solution because it is generally easier and a real coding time saver - I need to hedge my bets by linking in COM or NET objects or pushing Powershell code.

bmclellan


td

WIL Maps are the WIL implementation of associative arrays.  Navigate to Home -> Windows Interface Language Reference -> Functions -> Alphabetical -> MapCreate in the Consolidated WIL Help file for a concise explanation of WIL map usage.  Go to  Home -> Windows Interface Language Reference -> Functions -> By Type -> Maps (Associative Arrays) -> Map Functions in the Consolidated WIL Help file to get a brief definition of WIL maps.

If you do not have that information in your copy of the Consolidated WIL Help file, you are using an old version of WinBatch and it does matter.  You can't use them unless you get a newer copy of WinBatch+Compiler.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

((good gracious I love the new maps -- quick, clean, gets it done))
The mind is everything; What you think, you become.

chrislegarth

Maps are the next best thing to sliced bread!!!