Skip to content

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

FeatureDescription
Dictionary CompatibleProvides Keys/Items/RenameKey methods in Dictionary style
Key ManagementAccess and modify elements via Key or Index
SortingSort the collection by Key or Value
Safe UpdatesAdd method automatically handles duplicate Keys (overwrite update)
For Each SupportSupports 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)
Next

Checking 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

DocumentDescription
methods.mdMethod reference (Add, Remove, SortByKey, etc.)
properties.mdProperty reference (Count, Item, etc.)

🆚 Comparison with Standard Collection/Dictionary

FeatureCollectionDictionarycCollection
Key Access
Index Access-
Exists Check-
Keys/Items Methods-
Sorting--
Duplicate Key HandlingErrorOverwriteOverwrite
For Each Support

Last Updated: 2026-05-17

VB6 and LOGO copyright of Microsoft Corporation