Link to home
Start Free TrialLog in
Avatar of animazoo
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?
Avatar of kiprimshot
kiprimshot

Im not sure if this is what you want ...

Open yourFile For Output As #1

   then loop through listbox
      Print #1, listboxvalue
   end loop

Close #1


something like this

ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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



...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
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
Avatar of animazoo

ASKER

kiprim
sorry no it does not work
done it agin thanks
brookman
yes please
TimCottee
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