_MEMFILL - QB64 Wiki


From QB64 Wiki

Jump to: navigation, search

The _MEMFILL statement converts a value to a specified type then fills memory with that type including any non-whole remainder.


_MEMFILL memory_block, memory_block.OFFSET, fill_bytes, value [AS variable_type]


  • The memory block _MEM memory block is the block referenced to be filled.
  • The offset is the starting offset of the above referenced memory block.
  • The fill bytes is the number of bytes to fill the memory block.
  • The value is the value to place in the memory block at the designated OFFSET position.
  • A literal or variable value can be optionally set AS a variable type appropriate for the memory block.


  • To clear previous data from a _MEMNEW memory block, use _MEMFILL with a zero value.

Example: Filling array values quickly using FOR loops or a simple memory fill.

DIM a(100, 100) AS LONG DIM b(100, 100) AS LONG 'filling array a with value 13 FOR i1 = 0 TO 100 FOR i2 = 0 TO 100 a(i1, i2) = 13 NEXT NEXT 'filling array b with value 13 DIM mema AS _MEM mema = _MEM(b()) _MEMFILL mema, mema.OFFSET, mema.SIZE, 13 AS LONG _MEMFREE mema

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Personal tools