Transfer list box items to Excel


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Transfer list box items to Excel

  1. #1
    Join Date
    Aug 2005
    Posts
    19

    Transfer list box items to Excel

    Hello,

    I would like to transport the items I have in a listbox to an excel document. I would like to try the copy and paste method but I really don't know how to set it up. I've also tried the streamreader/writer process but I believe I've written the procedure wrong for that as well. This is the last step to a program I've been working on for a really long time and would appreciate any help at all. Thank you for your time.

    Dave

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Are you using VB.NET?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2005
    Posts
    19
    yes sir

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    To copy the contents of a ListBox (lstBox) to the clipboard, do this:
    Code:
    ' Imports System.Collections
    ' Imports System.Windows.Forms
    
    Dim alItems As New ArrayList
    For Each item As Object In lstBox.Items
        alItems.Add(item.ToString())
    Next
    Dim sData As String = String.Join(vbCrLf, _ 
        CType(alItems.ToArray(GetType(String)), String()))
    Clipboard.SetDataObject(sData)
    You may then paste the list into Excel, Notepad, etc. You may also find the following article helpful: http://support.microsoft.com/default...b;en-us;306022
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Saving from List box with Checkbox style
    By LD in forum VB Classic
    Replies: 1
    Last Post: 02-12-2003, 06:15 PM
  2. List box question
    By Jeff Pipes in forum .NET
    Replies: 4
    Last Post: 03-31-2002, 07:04 PM
  3. Select all items in a list box
    By Rich in forum Web
    Replies: 1
    Last Post: 03-17-2001, 06:15 AM
  4. Variable List Box Columns
    By Rick McLean in forum VB Classic
    Replies: 0
    Last Post: 02-06-2001, 06:05 PM
  5. Add New values to a list box on a form.
    By Gots in forum VB Classic
    Replies: 0
    Last Post: 10-14-2000, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center