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

    Need help with basic File I/O -

    I need help with basic file I/O in Access 97 and VB. simple things like how to open file and grab freefile handle , but also how do I keep a reference to this filehandle so that I can pass it to other functions.

    I am doing the following things
    open file
    write to file
    pass handle to another function which writes more text to file
    file close

    Help!


  2. #2
    Join Date
    Oct 1999
    Location
    CA
    Posts
    91

    Re: Need help with basic File I/O -

    Sounds to me like you need to take a look at the help files! There is alot of information in there.

    But to help ya, here:


    Dim strCurrentFile as string
    Dim intFileNumber as Integer

    'set the file stuff (path and number)
    strCurrentFile = "C:\My Documents\File.txt"
    intFileNumber = FreeFile

    'Open the file and write something to it.
    Open strCurrentFile for Output as intFileNumber
    print #intFileNumber, "This is text inside the file!"
    Close intFileNumber

    'Re open the file and get the string in it.
    Open strCurrentFile for input as intFileNumber
    input #intFileNumber, Text1
    Close intFileNumber





  3. #3
    Join Date
    Oct 1999
    Location
    S.W. Wyoming
    Posts
    25

    Re: Need help with basic File I/O -

    I see a previous reply has given you much information. To pass your file "handle" to a procedure which can then write more text to the file, simply pass, as an argument to that procedure the file number retrieved from FreeFile, and use that argument inside the procedure as your file number.

    Reid Allen Robbins
    2205 E. Teton Blvd.
    Green River, WY 82935

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