Click to See Complete Forum and Search --> : Need help with basic File I/O -
October 14th, 1999, 05:37 PM
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!
BrewGuru99
October 15th, 1999, 03:57 AM
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
Reid Robbins
October 15th, 1999, 08:37 AM
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.