VBA System.Collections.Queue

烈酒焚心 提交于 2019-12-10 21:48:20

问题


I just discovered here the 'built-in' Stacks and Queues available from VBA. The way it's written, I can't see the properties and methods of the Queue object.

Dim queue As Object
Set queue = CreateObject("System.Collections.Queue") 'Create the Queue

queue.Enqueue "Hello"   'VBE does not show the available properties and methods

So my question is: is there a reference I can use that will allow me to have early binding and benefit from the VBE autocomplete ? Something like:

Dim queue As System.Collections.Queue   'not working

回答1:


The Stack and Queue are COM objects from the .Net framework, they cannot be used with early binding. (as mentioned by @Florent B. in the comments).

However, if you need to see the properties of the COM object, you can always take a look at the MSDN site (it is quite explicit there): https://msdn.microsoft.com/en-us/library/system.collections.queue(v=vs.110).aspx

Or open a Visual Studio and check from there, the IntelliSense. Pretty much anything written there works:

Public Sub TestMe()    
    Dim myArr  As Variant        
    With CreateObject("System.Collections.Queue")
        .Clear
        .Enqueue (1)
        .Enqueue (2)
        myArr = .toArray
    End With
    Debug.Print myArr(1)        
End Sub


来源:https://stackoverflow.com/questions/48990783/vba-system-collections-queue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!