CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    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


  2. #2
    Join Date
    Dec 1999
    Location
    Slovakia
    Posts
    26

    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
  •  





Click Here to Expand Forum to Full Width

Featured