|
-
December 29th, 1999, 01:52 AM
#1
Files----Help, Very Urgent
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
-
December 29th, 1999, 04:06 AM
#2
Re: Files----Help, Very Urgent
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|