|
-
January 20th, 2000, 12:15 AM
#1
Get every item from listbox and write it to a file
i have "test1" and "test2" in a Listbox, how can I write them into a file so later on I can read from that file and use list1.additem to add strings "test1" and "test2" back into listbox
Thank You
-
January 20th, 2000, 02:40 AM
#2
Re: Get every item from listbox and write it to a file
to write the listbox contents to a file:
Dim yourfile as string
Dim i as Integer
yourfile = "c:\test.txt"
Dim hfile as Integer
hfile = FreeFile
Open yourfile for Output as #hfile
for i = 0 to lbx.ListCount - 1
print #hfile, lbx.List(i)
next i
Close hfile
-
January 20th, 2000, 03:12 AM
#3
Re: Get every item from listbox and write it to a file
Ok, now how do I read data from that file and reverse the process by putting what I have saved back into listbox
Thank You
-
January 20th, 2000, 03:16 AM
#4
Re: Get every item from listbox and write it to a file
private Sub Command2_Click()
Dim yourfile as string
Dim i as Integer
yourfile = "c:\test.txt"
Dim hfile as Integer
hfile = FreeFile
Open yourfile for input as #hfile
Dim strline as string
lbx.Clear
Do While Not EOF(hfile)
Line input #hfile, strline
lbx.AddItem strline
Loop
Close hfile
End Sub
-
January 20th, 2000, 03:59 AM
#5
Re: Get every item from listbox and write it to a file
-
January 20th, 2000, 06:31 AM
#6
Re: Get every item from listbox and write it to a file
It is faster enough instead of 'for' loop:
for i = 0 to lbx.ListCount - 1
print #hfile, lbx.List(i)
next i
to use 'for each' loop:
dim li as listitem
for Each li In YourListView.ListItems
print #hfile, li
next
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
-
January 20th, 2000, 07:06 AM
#7
Re: Get every item from listbox and write it to a file
may be you are right, but AndyK asked for a listbox solution. How would a for each loop look on a list box?
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
|