Bad Filename or Number Error 
Author Message
 Bad Filename or Number Error

CLEAR closes all open files and deletes all user-defined types as well as
zeroing out regular numeric variables and nulling string variables.  Get rid
of the CLEAR and zero out the variables yourself.
--
Interested in A FREE DSL Internet Connection?
E-mail me!

Tom Lake


Quote:
> Hello.  I am writing a program to catalog my book collection...the data
> entry form works fine until it tries to add it to the file, then I get an
> error message that says "Bad Filename or Number".  Any suggestions?

> TYPE BookInfo
>      name AS STRING * 100
>      author AS STRING * 100
>      copyright AS INTEGER
>      publisher AS STRING * 100
>      numPages AS INTEGER
>      printDate AS INTEGER
>      edition AS INTEGER
> END TYPE

> DIM book AS BookInfo

> OPEN "bookdata.dat" FOR RANDOM AS #1 LEN = LEN(book)

> menu:

>      CLEAR
>      o$ = ""
>      CLS
>      PRINT "(1) Add a new book"
>      PRINT "(2) View all records"
>      PRINT "(0) Exit"

>      a$ = INKEY$
>      IF a$ = "1" THEN GOSUB add
>      IF a$ = "2" THEN GOSUB recView
>      IF a$ = "0" THEN END

>      GOSUB menu

> add:
>      INPUT "Record number: ", record
>      LINE INPUT "Title: ", book.name
>      LINE INPUT "Author: ", book.author
>      INPUT "Copyright Date: ", book.copyright
>      LINE INPUT "Publisher: ", book.publisher
>      INPUT "Number of pages: ", book.numPages
>      INPUT "Print Date: ", book.printDate
>      INPUT "Edition: ", book.edition
>     'OK, the next line is where my problem is.
>     PUT 1, record, book
>      GOSUB menu

> recView:
>      INPUT "View record #", record
>      GET 1, record, book
>      PRINT "Title: ", book.name
>      PRINT "Author: ", book.author
>      PRINT "Copyright Date: ", book.copyright
>      PRINT "Publisher: ", book.publisher
>      PRINT "Number of pages: ", book.numPages
>      PRINT "Print Date: ", book.printDate
>      PRINT "Edition: ", book.edition
>      PRINT
>      PRINT "Press any key to continue..."
>      WHILE o$ = ""
>           o$ = INKEY$
>      WEND
>      GOSUB menu

> endProg:
>      CLOSE
>      END



Wed, 04 Sep 2002 03:00:00 GMT  
 Bad Filename or Number Error
Hello.  I am writing a program to catalog my book collection...the data
entry form works fine until it tries to add it to the file, then I get an
error message that says "Bad Filename or Number".  Any suggestions?

TYPE BookInfo
     name AS STRING * 100
     author AS STRING * 100
     copyright AS INTEGER
     publisher AS STRING * 100
     numPages AS INTEGER
     printDate AS INTEGER
     edition AS INTEGER
END TYPE

DIM book AS BookInfo

OPEN "bookdata.dat" FOR RANDOM AS #1 LEN = LEN(book)

menu:

     CLEAR
     o$ = ""
     CLS
     PRINT "(1) Add a new book"
     PRINT "(2) View all records"
     PRINT "(0) Exit"

     a$ = INKEY$
     IF a$ = "1" THEN GOSUB add
     IF a$ = "2" THEN GOSUB recView
     IF a$ = "0" THEN END

     GOSUB menu

add:
     INPUT "Record number: ", record
     LINE INPUT "Title: ", book.name
     LINE INPUT "Author: ", book.author
     INPUT "Copyright Date: ", book.copyright
     LINE INPUT "Publisher: ", book.publisher
     INPUT "Number of pages: ", book.numPages
     INPUT "Print Date: ", book.printDate
     INPUT "Edition: ", book.edition
    'OK, the next line is where my problem is.
    PUT 1, record, book
     GOSUB menu

recView:
     INPUT "View record #", record
     GET 1, record, book
     PRINT "Title: ", book.name
     PRINT "Author: ", book.author
     PRINT "Copyright Date: ", book.copyright
     PRINT "Publisher: ", book.publisher
     PRINT "Number of pages: ", book.numPages
     PRINT "Print Date: ", book.printDate
     PRINT "Edition: ", book.edition
     PRINT
     PRINT "Press any key to continue..."
     WHILE o$ = ""
          o$ = INKEY$
     WEND
     GOSUB menu

endProg:
     CLOSE
     END



Thu, 05 Sep 2002 03:00:00 GMT  
 Bad Filename or Number Error

Quote:
>CLEAR closes all open files and deletes all user-defined types as well as
>zeroing out regular numeric variables and nulling string variables.  Get rid
>of the CLEAR and zero out the variables yourse

In addition to the Clear statement deletion, I think you also need a # symbol
in the Put

Put #1,record, book  instead of
Put 1,record,book

Ray



Wed, 18 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. FileCopy Error 52 Bad FileName or number

2. Error - Bad Filename or Number

3. Bad filename or number

4. run time error "52": bad file name or number

5. Bad file name or number error 52

6. Setup caused runtime error 52 - bad file name or number

7. Bad file name or number error 52

8. Run-time error '52': Bad file name or number

9. Error 52 - Bad file name or number

10. error 52 invalid filename or number

11. Bad Function getfiledatetime(ByVal FileName As String) As Variant

12. Bound Controls: bad,bad,bad

 

 
Powered by phpBB® Forum Software