介绍 (Introduction)
在最近针对Excel社区的 article for the Excel community, I showed an improved version of the Excel Concatenate() function. While writing that article I realized that no one had written an EE article on a general purpose fast concatenation function for VB and VBA developers. The VB.Net community enjoys the StringBuilder class and that (fast concatenation) is a missing functionality for the VB/VBA developer. 文章中,我展示了Excel Concatenate()函数的改进版本。 在撰写该文章时,我意识到没有人针对VB和VBA开发人员撰写过有关通用快速连接功能的EE文章。 VB.Net社区喜欢StringBuilder类,而VB / VBA开发人员则缺少(快速串联)功能。If you are interested in the different performance characteristics of the intrinsic VB concatenation operators (& and +) and alternatives, please look at the prior article's attached VB project files and performance summaries.
如果您对固有VB串联运算符(&和+)和替代项的不同性能特征感兴趣,请查看上一篇文章随附的VB项目文件和性能摘要。
There are several different development environments in which to create and consume this functionality. I will use an Office 2003 environment for these examples.
有几种不同的开发环境可在其中创建和使用此功能。 这些示例将使用Office 2003环境。
设计课程 (Designing Our Class)
让我们穿上OOP护目镜片刻,讨论一下我们的设计。 我们需要将字符串追加到对象中并检索串联的字符串。 作为一个不错的功能,让我们提供在连接的字符串之间插入一些定界符文本的功能。We will need an ADD method that is passed a string.
我们将需要一个传递字符串的ADD方法。
We will need a TEXT property (read/write = set/get).
我们将需要一个TEXT属性(读/写=设置/获取)。
We will need a DELIMITER property (read/write = set/get).
我们将需要一个DELIMITER属性(读/写=设置/获取)。
We want our class to perform well, so we will add fast performance as decision criteria.
我们希望我们的班级表现良好,因此我们将快速表现作为决策标准。
创建课程模块 (Creating Your Class Module)
1.添加模块 (1. Add the module)
Open your code window (Alt+F11)
打开您的代码窗口(Alt + F11)
Insert | Class Module
插入| 类模块
This will add a Class Modules node to your current project and add a Class# module, where # is a sequential number, starting with 1.
这将在当前项目中添加一个Class Modules节点,并添加一个Class #模块&#