Results 1 to 5 of 5

Thread: HElp Needed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305

    HElp Needed

    Hi,i load a list box with the a list of names in,how could i save all those names one by one to diffrent txt files file thanks!

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016
    you want each name to a different file ?, if so try this.

    VB Code:
    1. Dim i As Integer
    2.  
    3. For i = 0 To List1.ListCount - 1
    4.  Open "C:\Name" & i + 1 & ".txt" For Output As #1
    5.   Print #1, List1.List(i)
    6.  Close #1
    7.   DoEvents
    8. Next i
    casey.

  3. #3
    Frenzied Member Tec-Nico's Avatar
    Join Date
    Jun 2002
    Location
    México
    Posts
    1,192
    In case you want to save them in the same folder your application is:

    VB Code:
    1. Dim i As Long
    2.  
    3. For i = 0 To List1.ListCount - 1
    4.  Open App.Path & "\" & List1.List(i) & ".txt" For Output As #1
    5.  Print #1, List1.List(i)
    6.  Close #1
    7.  DoEvents
    8. Next

    I just made some changes to vbasicgirl, I hope she doesn't mind.

    If you want them all in just one file:


    VB Code:
    1. Dim i As Long
    2.  
    3. Open App.Path & "\" & List1.Name & ".txt" For Output As #1
    4.  
    5. For i = 0 To List1.ListCount - 1
    6.  Print #1, List1.List(i)
    7. Next
    8.  
    9. Close #1
    We miss you, friend... Rest in Peace, we will take care of the rest of it.

    [vbcode]
    On Error Me.Fault = False
    [/vbcode]
    - Silence is the human way to share ignorance
    Tec-Nico

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    I think he wanted different files.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Posts
    305
    yeh i want it to say every diff name to a diff txt files like there 5 names so there be 5 txt files cheers :P

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