save list box to file? 
Author Message
 save list box to file?

i would like to know if i can save a list box to a file...it would be multi
line...thanks
simon wilkinson


Sun, 28 Sep 2003 01:13:57 GMT  
 save list box to file?


Quote:
>i would like to know if i can save a list box to a file...it would be multi
>line...thanks

Simon, this isn't the greatest (I'll have to look elsewhere for my Nobel
Prize :-) but it might give you a start.

A new VB6 .EXE with a listbox...

Private Sub Form_Load()

'Put some letters in the ListBox
For i = 0 To 9
    List1.AddItem Chr$(i + Asc("A"))
Next i
'And save them to a text file
Open "d:\myfile.txt" For Output As #1
For i = 0 To 9
    Print #1, List1.List(i)
Next i
Close #1
End Sub

Regards.

--
Martin Trump



Sun, 28 Sep 2003 01:49:15 GMT  
 save list box to file?


Quote:
> i would like to know if i can save a list box to a file...it would be
multi
> line...thanks
> simon wilkinson

This is an easy way to save the content of a listbox to a file:

Sub SaveListboxToFile(lstbox As Listbox, filename As String)
    Dim I As Integer
    Dim fNum As Integer
    If lstbox.ListCount = 0 Then Exit Sub
    fNum = FreeFile
    Open filename For Output As #fNum
    For I = 0 To lstbox.ListCount - 1
        Print #fNum, lstbox.List(I)
    Next I
    Close #fNum
End Sub

Usage:

SaveListboxToFile List1, "C:\directory\filename.lst"
SaveListboxToFile List1, "D:\VBProject\savedfiles\ListBox.txt"

Remember that this sub doesn't have any errorhandler so try to type the
correct filename or else a runtime error will popup.

Jan Magne Tjensvold



Mon, 29 Sep 2003 00:19:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. save list box to file?

2. Saving contents of a list box as a file

3. Help wanted with file list boxes and list boxes

4. Saving a combo/list box to file...

5. Reading file name from text box and/or File List Box

6. Listing files.TXT in a List Box

7. Adding multiple items from File Box to List box

8. VB6 - file list box / drive box question - resolving network paths and computer names

9. Highlight a File List box from an option box

10. 97:saving data from two multi-select list boxes

11. Saving contents of a list box

12. Help Saving Contents of List box

 

 
Powered by phpBB® Forum Software