• Welcome to Valhalla Legends Archive.
 

File Already Open

Started by CrAz3D, June 05, 2004, 05:57 PM

Previous topic - Next topic

CrAz3D

Public Sub WriteIt()
Dim iFile As Byte
On Error GoTo WriteER
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
Exit Sub
WriteER: Chat True, True, vbRed, "Database Writing Error: " & Err.Description
End Sub


Public Sub FillDB()
Dim s As String, d() As String, z As String
Dim iFile As Byte
frmDB.DB.ListItems.Clear
On Error GoTo FillER
iFile = FreeFile
   s = Dir(App.Path & "\database.db")
   If s = "" Then
       Open (App.Path & "\database.db") For Output As #iFile
       Close #iFile
   End If
Close #iFile

Open (App.Path & "\database.db") For Input As #iFile
Do Until EOF(iFile)
   Input #iFile, z
   d = Split(z, " ")
   frmDB.DB.ListItems.Add , , d(0)
       With frmDB.DB.ListItems(frmDB.DB.ListItems.Count)
           .ListSubItems.Add , , d(1)
           .ListSubItems.Add , , d(2)
       End With
Loop
Close #iFile

Exit Sub


When I try to look into my database (frmDB.DB, a listview) I recieve 'File Already Open' from the FillDB sub.  From what I've gathered, the file is not closing from the WriteIT sub.  Any ideas?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Eric

#1
Perhaps an error is occuring while attempting to fill the database.

CrAz3D

#2
Quote from: CrAz3D on June 05, 2004, 05:57 PM
From what I've gathered, the file is not closing from the WriteIT sub.

Hmm.......
Open (App.Path & "\database.db") For Input As #iFile
That is what is highlighted when the error occurs.  I'm sure sure how to make sure the thing is clsoed or not.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Dyndrilliac

The only thing I see that doesn't make sense is that your telling it:On Error GoTo FillERYet there is no "FillER" Section.....But that shouldn't be the cause of the problem.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

CrAz3D

FillER was listed below the Exit Sub, I just didn't copy everything I guess.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Stealth

Quote from: CrAz3D on June 06, 2004, 12:55 AM
FillER was listed below the Exit Sub, I just didn't copy everything I guess.

If your On Error code is blocking notification of an error that's happening in the above code, you won't be able to debug it. Take that statement out.

Also be sure to close the file that you have open in the error handling code:

FillER:
Close #iFile
Debug.print "Error! " & Err.number & " - " Err.Description
- Stealth
Author of StealthBot

CrAz3D

That worked Stealth, I ened up changing it all to #1, but it still worked.  Thanks.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...