animazoo
asked on
save to text file
Is there any way i can save from a listbox to a text file to show my figures like this
12345 12345 12345 12345 12345
12345 12345 12345 12345 12345 etc?
12345 12345 12345 12345 12345
12345 12345 12345 12345 12345 etc?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do you want to save all entries from the listbox?
open "c:\list.txt" for output as #1
for x=0 to list1.listcount - 1
print #1,list1.list(x) & " ";
if x/5 = fix(x/5) then
print #1,""
end if
next x
open "c:\list.txt" for output as #1
for x=0 to list1.listcount - 1
print #1,list1.list(x) & " ";
if x/5 = fix(x/5) then
print #1,""
end if
next x
...for the loop this would work or looping through indexes
Dim X As Integer
For X = 0 To listbox1.ListCount - 1
listbox1.Selected(X) = True
Print #1, Listbox1.text
Next X
Dim X As Integer
For X = 0 To listbox1.ListCount - 1
listbox1.Selected(X) = True
Print #1, Listbox1.text
Next X
use this:
Dim Filename As String
Dim iItem As Long
Filename = "c:\output.txt"
' Overwrite existing data
Open Filename For Output As #1
' Append to existing data
Open Filename For Append As #1
For iItem = 0 To List1.ListCount - 1
' Print one line in the textfile
Print #1, List1.List(iItem)
' Print data on same line
' Print #1, List1.List(iItem);
Next iItem
Close #1
Dim Filename As String
Dim iItem As Long
Filename = "c:\output.txt"
' Overwrite existing data
Open Filename For Output As #1
' Append to existing data
Open Filename For Append As #1
For iItem = 0 To List1.ListCount - 1
' Print one line in the textfile
Print #1, List1.List(iItem)
' Print data on same line
' Print #1, List1.List(iItem);
Next iItem
Close #1
ASKER
kiprim
sorry no it does not work
sorry no it does not work
ASKER
done it agin thanks
ASKER
brookman
yes please
yes please
ASKER
TimCottee
i cant see any further ref to this variable in your code
intColumns = 5 ' Number of columns across
i cant see any further ref to this variable in your code
intColumns = 5 ' Number of columns across
Sorry, that should have been For intItem1 = intItem To intItem + Step intColumns - 1 rather than For intItem1 = intItem To intItem + 4
Open yourFile For Output As #1
then loop through listbox
Print #1, listboxvalue
end loop
Close #1
something like this