Solved

Writing text files

Posted on 2000-05-11
2
117 Views
Last Modified: 2010-05-02
Hi,

I have a list box containing data. I need to get the program to write a text file containing the data possibly with the ability to re load it at a later date too.

can you help?

Cheers

Darude :)
0
Comment
Question by:darude
2 Comments
 
LVL 1

Accepted Solution

by:
manchula earned 50 total points
Comment Utility
   Open "C:\temp\testlist.txt" For Output As #1
    For i = 0 To List1.ListCount - 1
        Print #1, List1.List(i)
    Next
    Close #1
0
 
LVL 18

Expert Comment

by:deighton
Comment Utility
Private Sub Command1_Click()
    Call export(List1, "a:\temp.txt")
End Sub

Private Sub Command2_Click()
List1.Clear   'OMIT THIS TO ADD TE CONTENTS TO AN EXISTING LIST.
Call import(List1, "a:\temp.txt")
End Sub


Private Function export(list As Object, sfile As String)

    Dim n As Integer, c As Long
   
    n = FreeFile
   

    Open sfile For Output As n
       
    For c = 0 To list.ListCount - 1
       
        Print #n, list.list(c)
           
    Next
       
    Close n


End Function


Private Function import(list As Object, sfile As String)

    Dim n As Integer, sLine As String
   
    n = FreeFile
   

    Open sfile For Input As n
       
    While Not (EOF(n))
   
        Line Input #n, sLine
        list.AddItem sLine
       
    Wend
       
    Close n


End Function

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

728 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

9 Experts available now in Live!

Get 1:1 Help Now