Put Instruction

Syntax:

Put StreamNum, [RecordNum], var

Group:File

Description:
Write a variable's value to StreamNum.

Parameter Description

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordNum For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1. If this is omitted then the current position (or record number) is used.

  • var This variable value is written to the file. For a fixed length variable (like Long) the number of bytes required to store the variable are written. For a Variant variable two bytes that describe its type are written and then the variable value is written accordingly. For a usertype variable each field is written in sequence. For an array variable each element is written in sequence. For a dynamic array variable the number of dimensions and range of each dimension is written prior to writing the array values. All binary data values are written to the file in little-endian format.

    Note: When a writing string (or a dynamic array) to a Binary mode file the string length (or array dimension) information is not written. Only the string data or array elements are written.

See Also:Get, Open.

Example:

Sub Main
  Dim V As Variant
  Open "SAVE_V.DAT" For Binary Access Write As #1
  Put #1, , V
  Close #1
End
Sub