Results 1 to 6 of 6

Thread: Save Multiple Lists [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Save Multiple Lists [RESOLVED]

    ok i have a number of lists on my form and i only wana have one save button that will save all the lists in the same text file.

    VB Code:
    1. Dim x As Integer
    2. For x = 0 To List1.ListCount - 1
    3.   Open "C:/List.txt" For Append As #1
    4.     Print #1, List1.List(x)
    5.   Close #1
    6. Next x

    i have this which is ok but im not sure how to make it for all my lists. I have 7 lists all together. Any help welcomed. Thank you.
    Last edited by Ricky1; Mar 9th, 2005 at 06:59 PM.
    Im Learning !!!!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Save Multiple Lists

    VB Code:
    1. Dim ctl As Control
    2. Dim x As Integer
    3.  
    4. Open "C:/List.txt" For Append As #1
    5.  
    6. For Each ctl In Controls
    7.     If Typeof ctl Is Listbox Then
    8.         For x = 0 To ctl.ListCount - 1
    9.             Print #1, ctl.List(x)
    10.         Next x
    11.     End If
    12. Next
    13.  
    14. Close #1

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Save Multiple Lists

    thank you martinless do you have any idea how i would make the text file save in the same folder that the program was in ??
    Im Learning !!!!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Save Multiple Lists

    also wot im i doing wrong with this code?
    VB Code:
    1. Private Sub Label9_Click()
    2.  
    3. If Form1.Frame1.Visible = True Then
    4.     On Error Resume Next
    5.     With CommonDialog1
    6.     .CancelError = True
    7.     .Filter = "Text Files (*.txt)|*.txt|"
    8.     .ShowOpen
    9.     End With
    10.     Call SaveLoadListbox(List1, CommonDialog1.FileName, "load")
    11. End If
    12.  
    13. If Form2.Frame1.Visible = True Then
    14.     On Error Resume Next
    15.     With CommonDialog1
    16.     .CancelError = True
    17.     .Filter = "Text Files (*.txt)|*.txt|"
    18.     .ShowOpen
    19.     End With
    20.     Call SaveLoadListbox(List2, CommonDialog1.FileName, "load")
    21. End If
    22.  
    23. End Sub

    something to do with my If's because when i run the program and click frame1 and load it makes me choose the list twice. Probably because i got this code messed up but i can't see where.
    Im Learning !!!!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Save Multiple Lists

    lmao i c wot i did wrong above. but does any1 have any idea how to edit "MartinLiss" code above to make the text file same in the same folder as the program ??
    Im Learning !!!!

  6. #6

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