• Welcome to Valhalla Legends Archive.
 

Question: "File Already Open" Error

Started by DarkOne, February 27, 2004, 05:42 PM

Previous topic - Next topic

DarkOne

I continued my debugging this morning and found the problem. There was actually a problem in my SaveFilters procedure in which I was referring to a non-existent object. I have resolved this problem by ensuring that these objects are loaded.

I appreciate your help o.OV and everyone else to tried to help!

Stealth

Quote from: o.OV on February 28, 2004, 06:21 AM
"While Not" should be changed to "Until"

My CS teacher disagrees. He considers "While Not" better form. Perhaps from his background in C/C++?
- Stealth
Author of StealthBot

Newby

- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Grok

#18
Do While EOF(FileNum) = False    'or NOT EOF(FileNum)
  '
Loop


That is the form I always use for reading files in VB.  Even when using Scripting.TextStream object.

Set TS = fso.OpenTextStream(...)
Do While TS.AtEndOfStream = False
   '
Loop



DarkOne

Is there any advantage of using one over the other, other than typing less characters? Just a matter of preference?

Imperceptus

Now would be an excellent opportunity for you to Sharpen up on how to debug a program.  Step Into, Step over, variable/expression/control watches and so forth.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

o.OV

Quote from: DarkOne on February 28, 2004, 12:21 PM
I continued my debugging this morning and found the problem. There was actually a problem in my SaveFilters procedure in which I was referring to a non-existent object. I have resolved this problem by ensuring that these objects are loaded.

I appreciate your help o.OV and everyone else to tried to help!

oh.. strange.
I don't understand object oriented programming very well. :-\
How did a non-existent object cause a file to remain open?
If the facts don't fit the theory, change the facts. - Albert Einstein

o.OV

#22
Quote from: Stealth on February 28, 2004, 02:09 PM
Quote from: o.OV on February 28, 2004, 06:21 AM
"While Not" should be changed to "Until"

My CS teacher disagrees. He considers "While Not" better form. Perhaps from his background in C/C++?

I did try testing this.

Note:
I use two different projects
because I found the arrangement of code
could actually make a difference in speed.
(slower/faster)
Can someone give an explanation as to why?

Don't forget to compile into an executable ~ !!

Do While Not



Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Dim T As Long, X As Long, XX As Long
Private Sub Form_Load()
   
   Unload Me
   
   XX = 100000000
   X = 0
   T = GetTickCount
   Do While Not X
       XX = XX - 1
       If XX = 0 Then X = -1
   Loop
   MsgBox "Do While Not " & GetTickCount - T

End Sub



and

Do Until



Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Dim T As Long, X As Long, XX As Long
Private Sub Form_Load()
   
   Unload Me
   
   XX = 100000000
   X = 0
   T = GetTickCount
   Do Until X
       XX = XX - 1
       If XX = 0 Then X = -1
   Loop
   MsgBox "Do Until " & GetTickCount - T

End Sub

If the facts don't fit the theory, change the facts. - Albert Einstein

DarkOne

Quote from: o.OV on February 28, 2004, 09:16 PM
Quote from: DarkOne on February 28, 2004, 12:21 PM
I continued my debugging this morning and found the problem. There was actually a problem in my SaveFilters procedure in which I was referring to a non-existent object. I have resolved this problem by ensuring that these objects are loaded.

I appreciate your help o.OV and everyone else to tried to help!

oh.. strange.
I don't understand object oriented programming very well. :-\
How did a non-existent object cause a file to remain open?

I referred to the object while the file was open, but I don't quite understand why it didn't prompt me about the object. Odd.

o.OV

Quote from: DarkOne on February 28, 2004, 11:54 PM
I referred to the object while the file was open, but I don't quite understand why it didn't prompt me about the object. Odd.

Are you using "On Error .." ?
If the facts don't fit the theory, change the facts. - Albert Einstein

DarkOne

Nope.

If there are errors, I like to see what they are and fix them. I don't usually like to depend on "On Error Resume Next".

SPY-3

if you called a on error goto event where it opens the file then add Close#1 or w/e ur integer or number is