Solved

save to text file

Posted on 2001-06-15
10
166 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:animazoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 2

Expert Comment

by:kiprimshot
ID: 6195539
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

0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6195544
Dim strLine As String
Dim intItem As Integer
Dim intItem1 As Integer
Dim intColumns As Integer
intColumns = 5 ' Number of columns across
Open "MyFile.txt" For Output As #1
For intItem = 0 To List1.ListCount - 1
  strLine = ""
  For intItem1 = intItem To intItem + 4
    If intItem1 < List1.ListCount Then
      strLine = strLine & " " & List1.List(intItem1)
    End If
  Next
  Print #1,strLine
Next

0
 
LVL 2

Expert Comment

by:brookman
ID: 6195545
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



0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:kiprimshot
ID: 6195547
...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
0
 
LVL 2

Expert Comment

by:dwalsarie
ID: 6195556
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
0
 

Author Comment

by:animazoo
ID: 6195558
kiprim
sorry no it does not work
0
 

Author Comment

by:animazoo
ID: 6195574
done it agin thanks
0
 

Author Comment

by:animazoo
ID: 6195642
brookman
yes please
0
 

Author Comment

by:animazoo
ID: 6195648
TimCottee
i cant see any further ref to this variable in your code
intColumns = 5 ' Number of columns across
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6195654
Sorry, that should have been For intItem1 = intItem To intItem + Step intColumns - 1 rather than For intItem1 = intItem To intItem + 4
   
   
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question