# PutMem2
{: .no_toc }

Writes two bytes to a memory address.

Syntax: **PutMem2** *Address* **,** *Value*

*Address*
: *required* **LongPtr**. The address to write to.

*Value*
: *required* **Integer**. The 16-bit value to store at *Address*.

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

### Common Errors

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

### Example

This example writes a 16-bit value to a buffer and reads it back.

```tb check_build
Dim buf As LongPtr = AllocMem(4)
PutMem2 buf, &H1234
Dim v As Integer
GetMem2 buf, v          ' v = &H1234
FreeMem buf
```

### See Also

- [PutMem1](/tB/Modules/HiddenModule/PutMem1.md), [PutMem4](/tB/Modules/HiddenModule/PutMem4.md), [PutMem8](/tB/Modules/HiddenModule/PutMem8.md), [PutMemPtr](/tB/Modules/HiddenModule/PutMemPtr.md) procedures
- [GetMem2](/tB/Modules/HiddenModule/GetMem2.md) procedure
