|
-
Sep 19th, 2000, 07:58 PM
#1
Thread Starter
Fanatic Member
I have this code that saves everything in a list box line by line into a file. The compile gives me an error about EOF saying Argument Not Optional!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 07:59 PM
#2
Thread Starter
Fanatic Member
Sorry forgot the code
Code:
Dim ListC As Integer
Dim ListCi As Integer
ListC = List1.ListCount + 1
DoEvents
For ListCi = 1 To ListC
Open AccDat.ini For Output As #1
Do Until EOF
Print #1, List1.List(ListCi)
Loop
Close #1
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 08:07 PM
#3
Use this code. Makes life easier.
Code:
Public Sub List_Save(TheList As ListBox, FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
Hope that helps.
-
Sep 19th, 2000, 08:09 PM
#4
_______
<?>
you use until eof when reading not writing.
by the way..did you get the combo box resizing?
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 19th, 2000, 08:11 PM
#5
Thread Starter
Fanatic Member
you know where it says listcount - 1, I think that shoudl be + 1. Am i right or wrong.
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 08:17 PM
#6
Thread Starter
Fanatic Member
To heSaidJoe
Oh ok, I get yeah. Yes I did get the resizing and found out the problem and fixed it. But here's a question. How do you make it load the list back into the list box when you start the app
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 08:18 PM
#7
_______
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 19th, 2000, 08:20 PM
#8
Actually, isn't it something like:
Code:
Dim ListC As Integer
Dim ListCi As Integer
ListC = List1.ListCount + 1
DoEvents
For ListCi = 1 To ListC
Open "AccDat.ini" For Output As #1
Do While Not EOF(1)
Print #1, List1.List(ListCi)
Loop
Close #1
-
Sep 19th, 2000, 08:25 PM
#9
Thread Starter
Fanatic Member
oh yeah. I remember now. but can you help me with Loading the items back into the listbox when opening the application.
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 08:34 PM
#10
Thread Starter
Fanatic Member
I need someone's help fast!!!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Sep 19th, 2000, 08:39 PM
#11
_______
<?>
Code:
Option Explicit
Public Sub List_Save(TheList As ListBox, _
FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
Public Sub List_Load(TheList As ListBox, _
FileName As String)
On Error Resume Next
Dim Load As Long
Dim MyVar As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do While Not EOF(fFile)
Input #fFile, MyVar
List1.AddItem MyVar
Loop
Close fFile
End Sub
'load
Call List_Load(List1, "C:\My Documents\myfile.txt")
'
'save
Call List_Save(List1, "C:\My Documents\myfile.txt")
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 19th, 2000, 08:44 PM
#12
Thread Starter
Fanatic Member
Visual Basic 6.0
Visual C++ 5
Delphi 5

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
|