CitectVBA Programming Reference > CitectVBA Function Reference > File I/O Functions > Seek

Seek

Sets the current position within a file opened using the Open statement, ready for the next read or write action.

The required FileNum argument must contain an Integer representing any valid system file number associated with an open file.

The required Position argument must contain an Integer or expression representing a valid number.

Note: The file system keeps track of all open files and the current position of access within every file. Every statement or function that accesses the data within a file, alters the current position within that file. The Loc function can be used to determine the current position within an open file.

Syntax

SeekFileNum, Position

FileNum:

An Integer or numeric expression representing any valid number in the range 1 to 511 inclusive, which is referenced by the file system to be associated with an open file.

Position:

An Integer or expression representing a valid numeric value.

Related Functions

EOF | FileLen | Loc | LOF

Example

Open "TESTFILE" For Input As #1	' Open file for reading.
For i = 1 To 24 Step 3 ' Loop until end of file.
Seek #1, i ' Seek to byte position
MyChar = Input(1, #1) ' Read next character of data.
Print MyChar 'Print character of data
Next i
Close #1 ' Close file.