Solved

Writing text files

Posted on 2000-05-11
2
122 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
[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
2 Comments
 
LVL 1

Accepted Solution

by:
manchula earned 50 total points
ID: 2799407
   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
ID: 2799437
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

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