# Clear
{: .no_toc }

Removes all elements from a **Collection** object. After **Clear** returns, the collection's [**Count**](/tB/Modules/Collection/Count.md) is zero.

Syntax: *object*.**Clear**

*object*
: *required* An object expression that evaluates to a **Collection** object.

> [!NOTE]
>
> **Clear** is a twinBASIC extension; the classic VBA **Collection** object has no **Clear** method. The same effect in VBA requires repeatedly removing the first item until the collection is empty.

**Clear** resets a **Collection** to its initial, empty state --- useful when the object is to be reused without creating a new instance.

### Example

```tb check_build
Dim MyClasses As New Collection
MyClasses.Add "first"
MyClasses.Add "second"
MyClasses.Add "third"
Debug.Print MyClasses.Count   ' Prints 3.

MyClasses.Clear
Debug.Print MyClasses.Count   ' Prints 0.
```

### See Also

- [Count](/tB/Modules/Collection/Count.md) property
- [Remove](/tB/Modules/Collection/Remove.md) method
