Open files safely (Updated)
Category:
Files and DirectoriesType:
ModulesDifficulty:
BeginningAuthor:
Ruvenss Garcia WilchesVersion Compatibility: Visual Basic 6, Visual Basic 5
More information:
This is the fix update for the last code I submited on this version.
Instructions:
Create a new Module:
Named as FileFunctions
Copy And Paste the following code:
If you want to use it on your application just include again the module file on your proyect and during the forms or Components coding type FileFunctions. and VB will list the options
To open a file safely use this instructions
_________________________________________________
VerNewFile = FileFunctions.VerifyLong("test.txt")
'True as exist and False as Do not Exist
If VerNewFile = True Then
NewFile = filefunctions.ReadLocalFile("test.txt")
Do
lineinput #NewFile, txt$
Loop until eof(NewFile)
Close #NewFile
End if
__________________________________________________________
This way your applications will never open a busy file in precedent events, and the bugs percentage will be reduced.
May the code be with you folks
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: