Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on March 20, 2004, 12:11 PM

Title: Bad File Name or #
Post by: CrAz3D on March 20, 2004, 12:11 PM
I keep receiving this error when using my commands(the database is always saved after a commands is used)

Any ideas why I receive "Bad File Name of #"?...the file exsists
Public Sub WriteIt()
Close #1
Open (App.Path & "\database.db") For Output As #1
   For i = 1 To frmDB.DB.ListItems.Count
       Print #1, frmDB.DB.ListItems(i).text & " " & frmDB.DB.ListItems(i).ListSubItems(1).text & " " & frmDB.DB.ListItems(i).ListSubItems(2).text
   Next i
   Close #1
End Sub
Title: Re:Bad File Name or #
Post by: Adron on March 20, 2004, 12:37 PM
Maybe because you start by closing a file that's not open?
Title: Re:Bad File Name or #
Post by: Grok on March 20, 2004, 12:42 PM
Public Sub WriteIt()
   Dim iFile As Integer
   iFile = FreeFile
   Open (App.Path & "\database.db") For Output As #iFile
   For i = 1 To frmDB.DB.ListItems.Count
       Print #iFile, frmDB.DB.ListItems(i).text & " " & frmDB.DB.ListItems(i).ListSubItems(1).text & " " & frmDB.DB.ListItems(i).ListSubItems(2).text
   Next i
   Close #iFile
End Sub


Fixed for you.
Title: Re:Bad File Name or #
Post by: CrAz3D on March 20, 2004, 12:56 PM
Oooh, Grok = so 1337.

Thank you very much, I was attempting to do the same, but in a very primative way.
Input as #765 & so on