Results 1 to 2 of 2

Thread: [RESOLVED] Error 55 "File already open"

  1. #1

    Thread Starter
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 2008
    Location
    Right behind you.
    Posts
    165

    Resolved [RESOLVED] Error 55 "File already open"

    Error 55 "File already open". That's the error i get when my program tries to open the settings.dat file to update (write) the settings.

    First of all, the program uses the "Get text from line" function in form load to get all the settings line-after-line. Here is the function it uses:

    Code:
    Public Function GetTextFromLine(sFile As String, iLine As Long) As String
    Dim sText$, arText() As String, sLine$
        Open sFile For Input As #1
            'read entire file into a string variable
            sText = Input(LOF(1), #1)
            'split text into array
            arText = Split(sText, vbNewLine)
            'read specific line
            sLine = arText(iLine - 1)
        Close #1
        GetTextFromLine = sLine
    End Function
    And then when the program updates the settings using the "UpdateSettings" function, the error appears at Open Environ("temp") & "\Settings.dat" For Output As #SettingsFile

    Code:
    Public Function UpdateSettings(WhatLine As String, TextString As String)
    If InStr(WhatLine, "1") Then
    Part1 = TextString
    End If
    If InStr(WhatLine, "2") Then
    Part2 = TextString
    End If
    TSettings = Part1 & vbNewLine & Part2 'Part 2 and Part 1 will be joined back in to TSettings.text
    Dim SettingsFile As Long
    SettingsFile = FreeFile()
    Open Environ("temp") & "\Settings.dat" For Output As #SettingsFile 'Here is the error.
    Write #SettingsFile, (TSettings)
    Close #SettingsFile
    End Function
    Any idéa what's wrong?
    I think I am, therefore, I am. I think.

  2. #2

    Thread Starter
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 2008
    Location
    Right behind you.
    Posts
    165

    Re: [RESOLVED] Error 55 "File already open"

    Never mind, i solved it myself.
    I think I am, therefore, I am. I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width