Click to See Complete Forum and Search --> : Files----Help, Very Urgent


December 29th, 1999, 12:52 AM
How to open a file for both reading and writing in Visual Basic ? I don't want to open a file first for reading and then for writing. I want to open a file both for reading and writing.

Thanks for any help

ufo
December 29th, 1999, 03:06 AM
There are two kind of file access. One is VB and second you can use VB scripting library and FileSystemObject. This code snipet ilustrate first method VB binary access.


Dim FileNumber as Integer
Dim strTmp as string


FileNumber = FreeFile ' get unused file number.
Open "c:\tmp.txt" for binary Access Read Write Shared as #FileNumber ' Create file name.
Put #FileNumber, , "Line1." & vbCrLf ' Output text.
Put #FileNumber, , "Line2." & vbCrLf ' Output text.
strTmp = string$(5, " ")
get #FileNumber, 1, strTmp '/ set seek position to first byte and read first 5 byte
get #FileNumber, , strTmp '/ read next five an so on
Close #FileNumber ' Close file.
'/ you can use seek method current read/write position within a file




[ufo]