# vbaCopyBytesZero
{: .no_toc }

Copies a block of bytes from one address to another, then zeroes the source bytes.

Syntax: **vbaCopyBytesZero(** *Length* **,** *Dest* **,** *Src* **)** **As LongPtr**

*Length*
: *required* **Long**. The number of bytes to copy.

*Dest*
: *required* **LongPtr**. The destination address.

*Src*
: *required* **LongPtr**. The source address. The *Length* bytes starting at *Src* are written with zero after the copy completes.

Equivalent to a [**vbaCopyBytes**](/tB/Modules/HiddenModule/vbaCopyBytes.md) followed by a memory clear of the source. Useful when moving an owning resource (a BSTR, an interface pointer) without leaving a duplicate behind. The return value is *Dest*.

### Common Errors

| Error | When |
|---|---|
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | an argument is **Null** |

### Example

This example copies four bytes from one buffer to another, then confirms the source is zeroed.

```tb check_build
Dim src As LongPtr = AllocMem(8)
Dim dst As LongPtr = AllocMem(8)
PutMem4 src, &H12345678
vbaCopyBytesZero 4, dst, src    ' copy; src bytes are zeroed
Dim v As Long
GetMem4 dst, v                  ' v = &H12345678
GetMem4 src, v                  ' v = 0  (source was cleared)
FreeMem src
FreeMem dst
```

### See Also

- [vbaCopyBytes](/tB/Modules/HiddenModule/vbaCopyBytes.md) function
