GET([#]filenumber [,recnumber] ,varname)

Reads data from a text file into a record.


filenumberThe number of the file (Integer)
recnumber(Optional) The record number in a random file or byte number in a binary file where the writing should occur.
varname(Optional) The name of the variable you want to read to

REMARKS
* This statement can only be used with files opened with Binary or Random access.
* You can use the OPEN statement to open a file.
* You can use the PUT statement to write data from a record to a file.
* For the Microsoft documentation refer to docs.microsoft.com

Type recRecord 
   ID As Integer
   Text As String * 10
End Type

Sub Example()
   Dim mRecord As recRecord
   Open "C:\temp\MyText2.txt" For Random As #1 Len = Len(mRecord)
   mRecord.ID = 10
   mRecord.Text = "text 111"
   Put #1, 1, mRecord
   mRecord.ID = 20
   mRecord.Text = "22222"
   Put #1, 2, mRecord
   mRecord.ID = 30
   mRecord.Text = "33 text 33"
   Put #1, 3, mRecord
   Close #1

   Open "C:\temp\MyText2.txt" For Random As #1 Len = Len(mRecord)
   Get #1, 1, mRecord
   Debug.Print mRecord.ID & " - " & mRecord.Text
   Get #1, 2, mRecord
   Debug.Print mRecord.ID & " - " & mRecord.Text
   Get #1, 3, mRecord
   Debug.Print mRecord.ID & " - " & mRecord.Text
   Close #1
End Sub

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