How to write listbox items into text file ?

You can talk about VB programming here

How to write listbox items into text file ?

Postby method » Tue Nov 18, 2008 10:55 am


Hi all . Could any one show me how i can write the listbox items in to text file ? So far i all know to how to loop the listbox items. I want to the button re write all the listbox each time i press it.Looking forward for reply.Thanks

Code: Select all
Private Sub Command8_Click()
Dim i As Long

For i = 0 To List1.ListCount - 1
    'If List1.Selected(I) = True Then
        'MsgBox List1.Text
        MsgBox List1.List(i)
    'End If
Next
End Sub
method
imFiles Master
imFiles Master
 
Posts: 686
Joined: Tue Oct 18, 2005 11:12 am

Re: How to write listbox items into text file ?

Postby String » Tue Nov 18, 2008 3:51 pm

You can use this function to add all list items to a txtbox. Each item will be seperated by a comma [ , ]
Code: Select all
Function Lst2Str(List As listbox)
Dim X As Integer
Dim Z As String

    For X = 0 To List.ListCount - 1
        Z = Z & "," & List.List(X)
    Next
    Lst2Str= Z

End Function


In your command button use:
Code: Select all
Text1 = Lst2Str(List1)


Replace "Text1" and "List1" with what ever you need.
That help you any?
-= Please ask your questions in the forum, not in pm.
String
imFiles Senior
imFiles Senior
 
Posts: 313
Joined: Mon Mar 10, 2008 7:06 am
Location: IDE

Re: How to write listbox items into text file ?

Postby Chike » Tue Nov 18, 2008 4:43 pm

Here some gerber for ya.
Image
Chike
imFiles Master
imFiles Master
 
Posts: 583
Joined: Sun May 13, 2007 6:20 pm

Re: How to write listbox items into text file ?

Postby NVYE » Wed Nov 19, 2008 11:11 pm

Here is an application that suitable your needs:
http://www.vbforums.com/showthread.php?t=242778
Add-on Bots for educational and amusement purposes:
http://www.vnfox.com

Website:
http://www.asktechguy.com
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 234
Joined: Fri Jun 10, 2005 11:29 pm


Return to Visual Basic Programming

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests