PDA

View Full Version : Text file read/write.



sconly
11-22-2011, 04:05 AM
Is it possible to open a text file for reading and writing at the same time?

For example, I've got a text file and the only test in it is a reference number. I want to open the file, read the number, overwrite the number with a new one and then save the file. All in one fell swoop.

Is that possible or do i have to open the file for read, close it, then reopen for write and then save it?

Thanks.

Tinbendr
11-23-2011, 07:46 AM
You can use Random Access but you'll have to define a Record.

Help file example.
Type Record ' Define user-defined type.
ID As Integer
Name As String * 20
End Type

Dim MyRecord As Record ' Declare variable.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
' Close before reopening in another mode.
Close #1