Results 1 to 3 of 3

Thread: ***---Writing to a file, (formating)---***

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation

    i am writing a file using data from a list box, I have a bunch of names in a listbox that i want to save to a file. how do i do this. i am outputing to a text file(.txt)

    do i use the write function?? if yes or not how do i do it??

  2. #2
    Guest
    To save the listbox:

    Code:
    Public Sub List_Save(TheList As ListBox, FileName As String)
    On Error Resume Next
    Dim Save As Long
    Dim fFile As Integer
    fFile = FreeFile
    Open FileName For Output As fFile
       For Save = 0 To TheList.ListCount - 1
          Print #fFile, TheList.List(Save)
       Next Save
    Close fFile
    End Sub
    To load:

    Code:
    Public Sub List_Load(TheList As ListBox, FileName As String)
    On Error Resume Next
    Dim TheContents As String
    Dim fFile As Integer
    fFile = FreeFile
     Open FileName For Input As fFile
       Do
         Line Input #fFile, TheContents$
            TheList.AddItem TheContents$
       Loop Until EOF(fFile)
     Close fFile
    End Sub

  3. #3
    Member
    Join Date
    Oct 2000
    Posts
    47
    private function WriteListToFile
    Dim i As Integer
    'first create a textbox to contain all the names
    'by the way...there are many other ways how to do this function
    For i = 0 To List1.ListCount
    Text1.Text = Text1.Text & List1.List(i) & vbCrLf
    Next i
    open "c:\NewFile.txt" for output as #1
    print #1,text1.text
    close #1

    'walla!!
    DealMan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width