# GetMem4
{: .no_toc }

Reads four bytes from a memory address into a **Long** variable.

Syntax: **GetMem4** *Address* **,** *retVal*

*Address*
: *required* **LongPtr**. The address to read from.

*retVal*
: *required* **Long**. The variable to receive the value read from *Address*.

The bytes are interpreted in the host's native byte order --- little-endian on x86 and x64. The address is read directly with no bounds or alignment check.

### Common Errors

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

### Example

This example writes a 32-bit value to a buffer and reads it back with **GetMem4**.

```tb check_build
Dim buf As LongPtr = AllocMem(4)
PutMem4 buf, &H12345678
Dim v As Long
GetMem4 buf, v          ' v = &H12345678
FreeMem buf
```

### See Also

- [GetMem1](/tB/Modules/HiddenModule/GetMem1.md), [GetMem2](/tB/Modules/HiddenModule/GetMem2.md), [GetMem8](/tB/Modules/HiddenModule/GetMem8.md), [GetMemPtr](/tB/Modules/HiddenModule/GetMemPtr.md) procedures
- [PutMem4](/tB/Modules/HiddenModule/PutMem4.md) procedure
