Text files are also sometimes known as sequential files
There are three ways you can access file:
Sequential - This allows reading and writing of individual charactersor entire lines. You can start at the beginning and read forwards until you reach the end.
Random - This allows you to read and write record that all have the same length.
Binary - This allows you to read and write to specific byte positions within a file.
Private Function FileNameOnly(sFullPath As String) As String
Dim I As Integer
Dim length As Integer
Dim temp As String
Length = Len(sFullPath)
temp = ""
For I = length to 1 Step -1
If Mid(sFullPath,I,1) = Application.PathSeparator Then
FileNameOnly = temp
temp = Mid(sFullPath,I,1) & temp
FileNameOnly = sFullPath
The Dir function attempts to match its input argument against existing files.
This function can be used with valid wild cards under Windows for matches such as "*.xls".
If it finds a match, it returns the first match found and can be called again without an input argument to get subsequent matches.
Does a file exist
If Dir("C:\Temp.xls") <> "" Then
'then the file exists
Dim sFolderPath As String
If Dir(sFolderPath, vbDirectory) <> "" Then 'folder path exists
'folder path does not exist
There are three ways to access a file
This methods starts reading from the start and reads a line at a time
The Open statement is used to open your file.
You can specify the exact position in a file using the Seek() function.
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext