Solved

save to text file

Posted on 2001-06-15
10
167 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
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!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to incorporate an error traping routing to existing code in VB6 11 55
Recommendation vb6 to vb.net or others 14 241
VB6 ListBox Question 4 63
Advice in Xamarin 21 121
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

710 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