Solved

save to text file

Posted on 2001-06-15
10
158 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
  • 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now