Solved

Writing text files

Posted on 2000-05-11
2
124 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses
Course of the Month5 days, 3 hours left to enroll

635 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