0

I am using this code

Public Function Get_Settings(filename As String) As Boolean
    Dim recordlength As Integer
    recordlength = LenB(Settings)
On Error GoTo erroropeningsettingsfile
    Open filename For Random Access Read As #1 Len = recordlength
        Get #1, 1, Settings
    Close #1
    Get_Settings = True
    Exit Function
erroropeningsettingsfile:
    Get_Settings = False
End Function

if the file doesn't exists supposedly an error will be occurred and the error handler will execute, the code doesn't do what it supposed to do. why does it create a text file?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by SpiritualMadMan
0
' Return True if a file exists

Function FileExists(FileName As String) As Boolean
    On Error GoTo ErrorHandler
    ' get the attributes and ensure that it isn't a directory
    FileExists = (GetAttr(FileName) And vbDirectory) = 0
ErrorHandler:
    ' if an error occurs, this function returns False
End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.