PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 [RESOLVED] 3 Listbox save *.txt file-VBForums
Results 1 to 8 of 8

Thread: [RESOLVED] 3 Listbox save *.txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Resolved [RESOLVED] 3 Listbox save *.txt file

    i have 3 listbox and i want save .txt file please suggest


    in txt file
    V
    V

    Code:
    Listbox1       Listbox2          Listbox3 
       1               test                test
       2               ....                  ....
       ...              ....                  ...

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: 3 Listbox save *.txt file

    Welcome to the forums.

    Do you want each listbox saved to its own, individual, text file, or do you want all three listboxes saved to one text file?

  3. #3
    Banned
    Join Date
    May 2009
    Posts
    144

    Re: 3 Listbox save *.txt file

    Quote Originally Posted by sincere32 View Post
    i have 3 listbox and i want save .txt file please suggest


    in txt file
    V
    V

    Code:
    Listbox1       Listbox2          Listbox3 
       1               test                test
       2               ....                  ....
       ...              ....                  ...
    if u want to save the 1st item of each listbox then the 2nd of each then so on..

    you would write a basic function
    but first import an integer

    dim thisInt as integer=0

    public function SaveEachLine() as single
    try
    my.computer.filesystem.writealltext("C:\Users\YH\Documents\Filename.txt", listbox1.items(thisInt) & listbox2.items(thisInt) & listbox3.items(thisInt))
    thisInt += 1
    catch ex as exeption
    end try
    end function

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Re: 3 Listbox save *.txt file

    Quote Originally Posted by Hack View Post
    Welcome to the forums.

    Do you want each listbox saved to its own, individual, text file, or do you want all three listboxes saved to one text file?
    i want to save all thre listbox to one text file

  5. #5
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: 3 Listbox save *.txt file

    I would try something like this;
    Code:
            Using SW As New System.IO.StreamWriter("c:\somefile.txt")
    
                For iCount As Integer = 0 To ListBox1.Items.Count - 1
                    SW.WriteLine(ListBox1.Items.Item(iCount) & Chr(9) & ListBox2.Items.Item(iCount) & Chr(9) & ListBox3.Items.Item(iCount))
                Next
    
            End Using
    It seems to me like you are somewhat mimicking the functionality of a listview control. You might want to look into that and see if it doesn't better suit your needs.

    Good luck!

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Re: 3 Listbox save *.txt file

    thank you very much

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: 3 Listbox save *.txt file

    I assume all the three listboxes have same number of items.
    vb.net Code:
    1. Dim contents(ListBox1.Items.Count - 1) As String
    2. For i As Integer = 0 To ListBox1.Items.Count - 1
    3.     contents(i) = ListBox1.Items(i) & vbTab & ListBox2.Items(i) & vbTab & ListBox3.Items(i)
    4. Next
    5. IO.File.WriteAllLines("C:\Temp\myfile.txt", contents)
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." Charles F. Kettering

    Read articles on My Blog 101 LINQ Samples JSON Validator XML Schema Validator "How Do I" videos on MSDN VB.NET and C# Comparison Good Coding Practices VBForums Reputation Saver String Enum Super Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: 3 Listbox save *.txt file

    Quote Originally Posted by sincere32 View Post
    thank you very much
    Does this mean your question is resolved?

    If so, please help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width