SEEK - Function

SEEK(filenumber)

Returns the current read/write position within a file opened using the Open statement (Long).


filenumberThe number of the file (Integer).

REMARKS
* This function returns the position based on a file opened with the Open subroutine.
* The value returned is between 1 and 2,147,483,647.
* If the file access mode is Random, then the number returned is the next record read or written.
* If the file access mode is Binary, Output, Append or Input, then the byte position at which the next operation takes place is returned.
* You can use the OPEN statement to open a text file or csv file.
* You can use the INPUT statement to return the open stream of an Input or Binary file.
* You can use the PRINT statement to write display formatted data to a sequential file.
* You can use the SEEK Statement to reposition where the next operation in a file will occur.
* You can use the WRITE statement to write data to a Sequential file.
* The equivalent .NET function is Microsoft.VisualBasic.FileSystem.Seek
* For the Microsoft documentation refer to learn.microsoft.com

Type Record 
   ID As Integer
   Name As String
End Type

Dim myRecord As Record
Open "MyFile" For Random As #1 Len=Len(MyRecord)
Do While Not Eof(1)
   Get #1, 1, myRecord
   Debug.Print Seek(1)
Loop
Close #1

Dim myChar
Open "MyFile" For Input As #1
Do While Not Eof(1)
   myChar = Input(1, #1)
   Debug.Print Seek(1)
Loop
Close #1

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top