Skip to content

A collection of basic auxiliary classes and modules to complement VBA.

License

Notifications You must be signed in to change notification settings

HALTEC/VBA-commons-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VBA commons library

Basic auxiliary classes and modules to complement VBA

DESCRIPTION

This library is a collection of modules and classes to complement VBA. The library is not intended as a one stop solution for everything VBA. It contains components for IO, VBA datastructure handling, a Collection replacement, testing and some more.

Constructors

The classes in this package use a uniform, but non-standard mechanism for constructing objects. Each class is accompanied by a function in the Constructors module named ClassName_create() which returns a fully constructed instance of the repective class. These functions may take parameters. This approach provides a short object creation syntax:

List_create(1, 2, 3).elems ' 3

The mechanism does not primarily rely on the Class_Initialize() event. Each class provides one or more init() methods that may take parameters. This method is responsible for initialization of the class, but not for creating the object instance itself. The Constructors.ClassName_create() function creates a class instance, calls the init() method, forwarding all parameters it got, and returns the fully initialized instance.

Classes as Modules

Most of the modules in this library are actually implemented as Classes. The reason is to not fill up the global function namespace with all the different function names the modules provide. The functions can still be called without creating a class instance first by simply writing

ClassName.functionName()

This is made possible using a VB class attribute.

Attribute VB_PredeclaredId = True

When this attribute is attached to a class, VBA automatically creates an instance of that class on load and all method calls on the class name itself use that instance.

Attributes

This library makes use of VB class and method attributes in several places. These attributes are visible in the exported text files and thus also in this repository, but the VBA editor hides them, they are simply not visible anymore. When copying methods and classes textually in the VBA editor these attributes can get lost. To edit them one has to export the module/class to a text file, edit the attributes and import the module/class again. Exporting and importing is done via right mouse button on the class/module in the Project Explorer and then choosing Export/Import File....

CONTENTS

Arrays

The Arrays module provides functions to deal with array data structures. For example creating empty arrays or sorting arrays.

Collections

Auxiliary functions to work with the collection classes of this library (List, Map, ...).

DevUtils

Functions to help with development of this library itself.

IO

Simple file IO with good encoding support.

List

An optionally typed 0-based list implementation.

Map

An optionally typed map implementation.

Math

Common operations on numeric values. E.g. min(), max(), cmp()

Regexes

Functions to help with using the VBScript_RegExp_55.RegExp class.

Stringx

Common operations on string values. E.g. split(), join(), format()

Test

A minimal testing framework.

Variants

Common operations on Variant values. E.g. equals(), isArray(), gist()

XlUtils

Excel specific functions. E.g. rowColToExcel(), sheetExists(), isWorkbookOpen()

INSTALLATION

To import all the components of this library into an Excel file one can use the DevUtils.importModules() function. To use it, just import the DevUtils class manually into the VBA project and then call DevUtils.importModules "C:\path\to\this\repo\VBA-commons-lib". This will also automatically add all the necessary references to external libraries.

Some of these classes depend on others, but to some extent they can be used independently. So when one only wants a single class or module the easiest way is to only import that module, try to build and see which modules VBA is missing.

Especially all the Test_ modules only contain tests and need not be imported.

LICENSE

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

BUGS AND LIMITATIONS

Please report any bugs or feature requests through the web interface at https://github.com/HALTEC/VBA-commons-lib/issues.

AUTHORS

Patrick Böker <[email protected]>, originally based on code by Mathieu Guindon that can be found on Github.

About

A collection of basic auxiliary classes and modules to complement VBA.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages