Results 1 to 3 of 3

Thread: Listbox to textfile??

  1. #1

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460

    Listbox to textfile??

    How can i save my listboxcontents to a file (.txt file)...

  2. #2
    sunnyl
    Guest
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()   'saves
    4.     Dim LoopCount As Integer
    5.    
    6.     Open "c:\test.txt" For Output As #1
    7.    
    8.     For LoopCount = 0 To List1.ListCount - 1
    9.         Print #1, List1.List(LoopCount)
    10.     Next
    11.    
    12.     Close #1
    13. End Sub
    14.  
    15.  
    16. Private Sub Command2_Click()    'loads
    17.     Dim Data As String
    18.    
    19.     Open "c:\test.txt" For Input As #1
    20.    
    21.     Do Until EOF(1)
    22.         Line Input #1, Data
    23.         List1.AddItem Data
    24.     Loop
    25.    
    26.     Close #1
    27. End Sub
    28.  
    29. Private Sub Form_Load()
    30.     List1.AddItem "1"
    31.     List1.AddItem "2"
    32.     List1.AddItem "3"
    33. End Sub

  3. #3

    Thread Starter
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Thanx! Works perfect...

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