VBA System.Collections.Queue [英] VBA System.Collections.Queue

查看:56
本文介绍了VBA System.Collections.Queue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现了这里VBA 提供的内置"StacksQueues.它的编写方式,我看不到 Queue 对象的属性和方法.

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

所以我的问题是:有没有我可以使用的参考,可以让我提前绑定并从 VBE 自动完成中受益?类似的东西:

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

推荐答案

StackQueue 是来自 .Net 框架的 COM 对象,它们不能用于早期捆绑.(正如@Florent B. 在评论中提到的那样).

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).

但是,如果您需要查看 COM 对象的属性,您可以随时查看 MSDN 站点(那里非常明确):https://msdn.microsoft.com/en-us/library/system.collections.queue(v=vs.110).aspx

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

或者打开 Visual Studio 并从那里检查 IntelliSense.几乎所有写在那里的东西都有效:

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

这篇关于VBA System.Collections.Queue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆