Solved System.Collections ?? (1 Viewer)

jdraw

Super Moderator
Staff member
Local time
Today, 14:14
Joined
Jan 23, 2006
Messages
15,379
In the past I have been able to use/reference system.collections to be able to work with Stack, Queue, ArrayList etc.
I now have a new laptop and have move my O365 account to it. In addition I have moved to Office 64 bit.
Bottom line is the previous code using System.Collections now fails -automation error???

Does anyone have experience/advice on how to restore the ability to reference System.Collections with Access vba?

Sample from previous O365 32 bit that used to work, but now errors.
Code:
Sub TestQueue()
    Dim obj As Object
    Set obj = CreateObject("System.Collections.Queue")
    obj.enqueue 4
    obj.enqueue 8
    obj.enqueue 12
   
    Dim vloop As Variant
    For Each vloop In obj
        Debug.Print vloop
    Next
   
    Debug.Assert obj.peek = 4
    Debug.Assert obj.Count = 3
    Debug.Assert obj.dequeue = 4
    Debug.Assert obj.Count = 2
    Debug.Assert obj.peek = 8
    Debug.Assert obj.dequeue = 8
    Debug.Assert obj.dequeue = 12
    Debug.Assert obj.Count = 0
End Sub

Update: This is one of the sources I had for investigating System.Collections from late 2019.
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 14:14
Joined
Apr 27, 2015
Messages
6,341
Hi Jack, I did a GDB for that particular error and the ONLY hit I found was from 2015 thread. Here it is, I sure you read it but you never know.

The gist is that is is a Windows OS thing and maybe not Office/Access
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:14
Joined
Jan 23, 2006
Messages
15,379
Hi John, Thanks for responding. I hadn't seen that link, but I started "toying" with system.collections in late 2019 after finding some stuff via Google etc., so I don't think it's the same issue. I have found 1 link that said you need Net Framework 3, but another said he tested it with 4 successfully. It appears that I have 1.0, 1.1, 2.0 and 4.0 on this laptop. It's an area where I really have no technical understanding, but hopefully there are some(or 1) out there that know(s) the specifics. Hard to believe that it (ability to reference that library) may have been removed???

I just found another reference saying version 3.5 MUST be installed. ( I do watch and recommend Paul Kelly)

What is nice about system.collections is that you get access to some classes that are not intrinsic to vba. (stack, queue, array list)

As an aside, here is a great link for data structures overview from freeCodecamp.org
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Today, 14:14
Joined
Jan 23, 2006
Messages
15,379
Solved: I downloaded and installed Net Framework 3.5 as per the article from Paul Kelly referenced in post#3.
The code executes without error.
 

Users who are viewing this thread

Top Bottom