如何在Visual Basic for Applications中使用“类模块”或“模块”?

时间:2022-06-22 16:37:54

I'm trying to create a collection in and can't figure out how to do this. Can anyone either explain this to me or send me off to some links?

我正在尝试在vba中创建一个集合,但无法弄清楚如何执行此操作。任何人都可以向我解释这个或发送给我一些链接?

I've been working on this same "language issue" for several hours. I've checked SO, google, MSDN, and F1 help to no avail.

几个小时以来,我一直在研究同样的“语言问题”。我已经检查过SO,谷歌,MSDN和F1帮助无济于事。

2 个解决方案

#1


2  

Can you pls be more explicit about the collection you are looking to make - a collection of a number of the better class modules and collection links below.

你能不能更清楚地了解你想要制作的集合 - 下面是一些更好的类模块和集合链接的集合。

Class Modules

类模块

  1. Walkenbacks colour button class module
  2. Walkenbacks颜色按钮类模块
  3. Pearson on class modules
  4. Pearson上课模块
  5. Peltier, Chart event class module
  6. Peltier,Chart事件类模块

Dictionaries v Collections

字典v集合

  1. Patrick Matthews Using the Dictionary Class in VBA
  2. Patrick Matthews在VBA中使用字典类

#2


3  

The basic approach is:

基本方法是:

Declare a Collection object

声明一个Collection对象

Dim oCol As Collection

Create an instance of the object

创建对象的实例

Set oCol = New Collection

Add things to the collection

添加东西到集合

oCol.Add Item:=1, Key:="Item1IsANumber"
oCol.Add Item:="SomeString", Key:="Item2IsAString"

Refer to the items

请参阅项目

z = oCol.Item(1)  ' z = 1
z = oCol.Item(2)  ' z = "SomeString"
z = oCol.Item("Item1IsANumber")  ' z = 1
z = oCol.Item("Item2IsAString")  ' z = "SomeString"

CPearson.com is a good reference for lots of things vba

CPearson.com是很多东西vba的很好的参考

Here's a Link to a collections page

这是一个收集页面的链接

#1


2  

Can you pls be more explicit about the collection you are looking to make - a collection of a number of the better class modules and collection links below.

你能不能更清楚地了解你想要制作的集合 - 下面是一些更好的类模块和集合链接的集合。

Class Modules

类模块

  1. Walkenbacks colour button class module
  2. Walkenbacks颜色按钮类模块
  3. Pearson on class modules
  4. Pearson上课模块
  5. Peltier, Chart event class module
  6. Peltier,Chart事件类模块

Dictionaries v Collections

字典v集合

  1. Patrick Matthews Using the Dictionary Class in VBA
  2. Patrick Matthews在VBA中使用字典类

#2


3  

The basic approach is:

基本方法是:

Declare a Collection object

声明一个Collection对象

Dim oCol As Collection

Create an instance of the object

创建对象的实例

Set oCol = New Collection

Add things to the collection

添加东西到集合

oCol.Add Item:=1, Key:="Item1IsANumber"
oCol.Add Item:="SomeString", Key:="Item2IsAString"

Refer to the items

请参阅项目

z = oCol.Item(1)  ' z = 1
z = oCol.Item(2)  ' z = "SomeString"
z = oCol.Item("Item1IsANumber")  ' z = 1
z = oCol.Item("Item2IsAString")  ' z = "SomeString"

CPearson.com is a good reference for lots of things vba

CPearson.com是很多东西vba的很好的参考

Here's a Link to a collections page

这是一个收集页面的链接