Search code examples
qbasic

"bad file mode" error in qbasic


I am just starting with file handling in qbasic. The program that I wrote always shows an error "bad file mode". Please help me!

OPEN "test.dat" FOR INPUT AS #1
CLS
INPUT "Enter username:"; a$
INPUT "Enter Password:"; b$
WRITE #1, a$, b$
CLOSE #1
END

Solution

  • If you want to WRITE output to a file then, logically, you might want to try this:

    OPEN "test.dat" FOR OUTPUT AS #1
    CLS
    'etc