Valhalla Legends Forums Archive | Visual Basic Programming | Bad File Name or #

AuthorMessageTime
CrAz3D
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
[code]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[/code]
March 20, 2004, 6:11 PM
Adron
Maybe because you start by closing a file that's not open?
March 20, 2004, 6:37 PM
Grok
[code]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[/code]

Fixed for you.
March 20, 2004, 6:42 PM
CrAz3D
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
March 20, 2004, 6:56 PM

Search