# InterlockedExchangePointer
{: .no_toc }

Atomically exchanges a pointer-sized value at a memory location and returns the previous value.

Syntax: **InterlockedExchangePointer(** *Target* **,** *NewValue* **)** **As LongPtr**

*Target*
: *required* **LongPtr**. The pointer-sized variable to update, passed by reference.

*NewValue*
: *required* **LongPtr**. The new value to store at *Target*.

The store and the read of the prior value happen as a single atomic operation, observable by other threads as either fully-before or fully-after the call. Wraps the Win32 `InterlockedExchangePointer` intrinsic.

### Common Errors

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

### See Also

- [InterlockedCompareExchangePointer](/tB/Modules/HiddenModule/InterlockedCompareExchangePointer.md) function
- [InterlockedCompareExchange32](/tB/Modules/HiddenModule/InterlockedCompareExchange32.md), [InterlockedCompareExchange64](/tB/Modules/HiddenModule/InterlockedCompareExchange64.md) functions
