Results 1 to 6 of 6

Thread: run-time error 54

  1. #1

    Thread Starter
    Lively Member deranged's Avatar
    Join Date
    Jun 2004
    Location
    TN
    Posts
    104

    run-time error 54

    VB Code:
    1. Private Sub Form_Load()
    2. Open "c:\TEXT.TXT" For Output As #1
    3.     Get #1, , fileinfo
    4. Close #1
    5. Text1.Text = fileinfo
    6. End Sub


    runtime error 54 "bad file mode". Highlights the 'get #1, , fileinfo" string of code


    Any help would be appreciated

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You have opened the file for output, which means that you intend to write to the file. The Get statement is used during file input.

    But I'm not sure you can even use Get when opening for Input, I though it was only used for Random and Binary.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Lively Member deranged's Avatar
    Join Date
    Jun 2004
    Location
    TN
    Posts
    104
    *edit* using random works. but now we're on a different problem:


    error 458:

    Variable uses an automation type not supported in Visual Basic


    The text file contains:

    "ASD"
    Last edited by deranged; Jun 28th, 2004 at 02:31 PM.

  4. #4
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734
    Have you defined fileinfo as a variable...

  5. #5
    Hyperactive Member Vishalgiri's Avatar
    Join Date
    Oct 2003
    Location
    India
    Posts
    345

    datatype

    Please use a buffer while working with files but you have to Declare the type of that variable first, so
    Code:
    Private Sub Form_Load()
    Dim strFileInfo
    Open "c:\TEXT.TXT" For Input As #1
        Get #1, , strFileInfo
    Close #1
    Text1.Text = strFileInfo
    End Sub
    By the way
    You can also use relative path for file you wants to open.
    Regards,
    Vishalgiri Goswami
    Gujarat, ( INDIA ).
    ---------------------

  6. #6

    Thread Starter
    Lively Member deranged's Avatar
    Join Date
    Jun 2004
    Location
    TN
    Posts
    104
    that was also a solution. however i get another problem now.



    error 59:
    bad record length

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