Results 1 to 14 of 14

Thread: Printing the contents of a listbox [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162

    Printing the contents of a listbox [RESOLVED]

    Here's a question for the masses. I am writing a program and i want to print the information in a list box.

    I'm sure it's easy, but i can't seem to get it to work.
    I'd appreciate the help
    Last edited by SuperChris9; Jan 24th, 2004 at 11:00 PM.

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    See if lesson 16 helps you

    http://www.free-ed.net/fr03/lfc/030202/120/

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162
    yeah, it didn't really help. I know the concept of how to print, i'm just having trouble figure out what property to send to the printer or some way of dumping the contents of the listbox to the printer. I have tried printer the text, list, itemdata properties, but just get a blank page, or an error.
    Last edited by SuperChris9; Jan 24th, 2004 at 10:09 PM.

  4. #4
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Would it be easier to save the contents of the list box to a .txt file and then have VB print the .txt file?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162
    i could do that, but, then i'd have to clear the text file after everyprint, but what i'm trying to do is add a deli order to a list box and send it to a printer, if there is an easier idea on how to do it, i'm totally up to it

  6. #6
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    You wouldnt have to clear the text file, when you write a new one, it will overwrite the old one.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162
    ok, then i'll do that, but how do i save the contents of the listbox to a text file then. Like i have said before, i'm trying to relearn all of this

  8. #8
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Try this link, its a routine I made for someone else not long ago. You can modify it for your needs I think. If not, let me know and I'll lend a hand.

    http://www.vbforums.com/showthread.p...highlight=list

  9. #9
    Addicted Member imbue's Avatar
    Join Date
    Aug 2002
    Location
    Midwest USA
    Posts
    155
    Maybe I'm missing the point, but why not just do this?

    VB Code:
    1. Dim x As Long
    2. For x = 0 To List1.ListCount - 1
    3. Printer.Print List1.List(x)
    4. Next x

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162
    hey, thanks alot but, i figured it out. this was the code i used:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim intx As Integer
    3.     For intx = 0 To List1.ListCount
    4.     Printer1.Print List1.List(intx)
    5.     Next intx
    6. End Sub

    it seems like that shoulda been such an obvious answer ::smacks head::

  11. #11
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Make sure you use the -1 or you wont get the first item.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    162
    I still got the first item, the list index goes from -1 and up, but the first items is at zero isn't it, well anyway i still got the first item in the list

  13. #13
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358
    Along the same lines, how do I print the contents of a datagrid? This is probably very simple but I'm a bit stupid!

    Tar.
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  14. #14
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    HELP!!

    ...or....

    put the contents of the datagrid to Excel?!

    Cheers!
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

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