cCollection Overview
📖 Introduction
cCollection is an enhanced version of the VB Collection class that adds Dictionary-compatible methods, sorting, and key management features on top of the standard Collection.
✨ Key Features
| Feature | Description |
|---|---|
| Dictionary Compatible | Provides Keys/Items/RenameKey methods in Dictionary style |
| Key Management | Access and modify elements via Key or Index |
| Sorting | Sort the collection by Key or Value |
| Safe Updates | Add method automatically handles duplicate Keys (overwrite update) |
| For Each Support | Supports VB standard iteration syntax |
🚀 Quick Start
Creating a Collection and Adding Elements
vb
Dim col As New cCollection
' Add elements with Key
col.Add "John", "user1"
col.Add "Jane", "user2"
' Add elements without Key
col.Add "Plain element"Accessing Elements
vb
' Access by Key
Dim name As String
name = col.Item("user1")
' Access by Index (starts from 1)
name = col.Item(1)
' Short form (default property)
name = col("user1")Iterating Through Collection
vb
' For Each iteration
Dim item As Variant
For Each item In col
Debug.Print item
Next
' Iterate by index
Dim i As Long
For i = 1 To col.Count
Debug.Print col(i)
NextChecking if Key Exists
vb
If col.Exists("user1") Then
Debug.Print "User exists"
End If
' Case-insensitive (default)
If col.Exists("USER1") Then ' Returns True📁 Documentation Navigation
| Document | Description |
|---|---|
| methods.md | Method reference (Add, Remove, SortByKey, etc.) |
| properties.md | Property reference (Count, Item, etc.) |
🆚 Comparison with Standard Collection/Dictionary
| Feature | Collection | Dictionary | cCollection |
|---|---|---|---|
| Key Access | ✓ | ✓ | ✓ |
| Index Access | ✓ | - | ✓ |
| Exists Check | - | ✓ | ✓ |
| Keys/Items Methods | - | ✓ | ✓ |
| Sorting | - | - | ✓ |
| Duplicate Key Handling | Error | Overwrite | Overwrite |
| For Each Support | ✓ | ✓ | ✓ |
Last Updated: 2026-05-17