Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 19th, 2007, 03:41 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Closing Files

Well, in my app the user can open files which are obviously by code opened for input nd displayed into a grid which works fine (not hard to do at all) but when i they want to open another file the open dialog returns an error saying file already open even if its a different file completely! Why is that? When i open a file for input i do make sure that the file is closed afterwards!

------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
__________________
Apocolypse2005, I'm a programmer - of sorts.
  #2 (permalink)  
Old August 21st, 2007, 07:10 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

are you using a diferent file number for each one??

how do you open it??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
  #3 (permalink)  
Old August 21st, 2007, 02:10 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

well i use this code
Code:
On Error GoTo DiEr

With cdSave
    .CancelError = True
    .DialogTitle = "Load Library"
    .Filter = "All Librarys(*.lstlib)|*.lstLib"
    .FilterIndex = 1
    .InitDir = App.Path

    .ShowOpen
  
    ReadPlaylist (.FileName)
End With

DiEr:
     If Err.Number = 32755 Then
        Exit Sub
    Else
    MsgBox Str(Err.Number) & ": " & Err.Description, vbCritical, "Error"
    End If
Which is the button handler and this code to open the file
Code:
Sub ReadPlaylist (sPath As String)
Open sPath For Input As #1
'code is executed in here!
Close #1

------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
  #4 (permalink)  
Old August 21st, 2007, 02:17 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. you are using the same number for every file.. use freefile to get a new number for a file.. that way you avoid trying to open one file in top of another...
Code:
dim i as integer
i = freefile
open file for input as i '(or was #i I don't remember)
HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing a Page. akhilhp ASP.NET 2.0 Basics 3 May 1st, 2007 10:03 AM
Form closing bschleusner C# 2005 2 February 4th, 2007 04:07 PM
VB not closing goLynxgo XML 0 January 26th, 2005 05:44 PM
Delete files on closing browser spacy ASP.NET 1.x and 2.0 Application Design 7 September 8th, 2004 04:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.