|
-
Aug 3rd, 2000, 04:25 PM
#1
Thread Starter
Member
Sometimes I get an error when performing this code, anyone know how to avoid this error? Trying to Append Open File
Private Sub Save_Click()
Dim i As Integer
Open "events.txt" For Append As #1
For i = 0 To Events.ListCount
Print #1, Events.List(i)
Next i
For i = 0 To Players.ListCount
Print #1, Players.List(i)
Next i
'Save the text from Text1 as well
Print #1, Session.text
Print #1, Map.text
Print #1, MaxScore.text
Print #1, MaxTime.text
Print #1, MaxTons.text
Close #1
End Sub
Vince McMullin
Aka Vam, Vinny Mac
Its just that simple
-
Aug 3rd, 2000, 04:39 PM
#2
_______
<?>
what is the error...is it nothing in the listindex?
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 04:44 PM
#3
transcendental analytic
This could be the error, The listitems are starting from 0, not 1.
Code:
For i = 0 To Events.ListCount - 1
Print #1, Events.List(i)
Next i
For i = 0 To Players.ListCount - 1
Print #1, Players.List(i)
Next i
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 3rd, 2000, 04:46 PM
#4
Thread Starter
Member
The error happens randomly and it says "Trying to Append All ready open file"
Then it closes....... Ok If I restart my app its ok.
The textfiles and listboxes contain information yes..... It doesn't crash if they don't either
Basically I think that if I open events.txt (which I did) and then close that for someone reason Appen seems to think its still open after I close it.
Vince McMullin
Aka Vam, Vinny Mac
Its just that simple
-
Aug 3rd, 2000, 05:14 PM
#5
transcendental analytic
Instead of #1 you should put a filenumber you know is free
Like this:
Code:
Dim ff as integer
ff=Freefile
Open "events.txt" For Append As ff
.
.
Print #ff, Events.List(i)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 3rd, 2000, 05:17 PM
#6
Hyperactive Member
I know that on occasion, I can find myself getting an error like that when I am working in a hurry and not using the FreeFile function. You might give it a try, doing something like this:
Code:
Private Sub Save_Click()
Dim i As Integer
Dim FF as integer
FF=FreeFile
Open "events.txt" For Append As FF
'If you loss the Next i bit and just make it Next,
'you will notice a speed increase on large loops.
If Events.ListCount<>0 then
For i = 0 To Events.ListCount
Print #FF, Events.List(i)
Next
End if
If Players.ListCount<>0 then
For i = 0 To Players.ListCount
Print #FF, Players.List(i)
Next
End if
'Save the text from Text1 as well
Print #FF, Session.text & Map.text & MaxScore.text & _
MaxTime.Text & MaxTons.Text
Close FF
End Sub
Hope this is helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|