I am using a sequentail file in one of my VB forms. I first read the file to extract information. When I am done I close it. The exact code I use is:
FileName = App.Path & filDetectTemp
OutputFileNo = FreeFile
Open FileName For Output As #OutputFileNo
' Open Input File and Start Reading
FileName = App.Path & filDetect
InputFileNo = FreeFile
Open FileName For Input As #InputFileNo
Do While Not EOF(InputFileNo)
Line Input #InputFileNo, linebuffer
' linebuffer = Crypt(linebuffer)
CopyMemory TempDetect, ByVal linebuffer, Len(TempDetect)
' when reading through detection always want to bypass level "00" (baselevel) records for
' this evaluation.
' If it is an upgrade will also want to bypass any upgrades of that level
If TempDetect.Eval_ID = whichEval Then
If TempDetect.DOLevel = BaseLevel Or TempDetect.DOLevel = whichLevel Then
' write output record from input to output
CopyMemory ByVal linebuffer, TempDetect, Len(TempDetect) - 2
Print #OutputFileNo, linebuffer
The next thing I do in the same program is use the name statement to copy the input file to a backup using:
Name App.Path & filDetect As App.Path & filDetectBack
The system is giving me an error that file is open. The file it is indicating is App.Path & filDetect. This logic is immediately after the close. Why wouldit tell me the file was still open?
I have a book with a 'Tip' that says: The Reset command, unlike the Close command seems to force the underlying operating system to flush the buffers. Use this command in critical sitiations to make sure that the underlying operating system file buffer is flushed. However it stops there. I have no sysntax on the Reset command. Do I use it instead of the close command? What is the format/syntax?