Link to home
Start Free TrialLog in
Avatar of its_ajt
its_ajt

asked on

Printing with List Boxes

I have a large List Box on a Form full of items added using the "Additem" method. How do I print:
 
i)everything (all the items) into a report?
ii) only the selected (checked) items into a report?

NB I'm using VB5 Enterprise Edition.
Avatar of its_ajt
its_ajt

ASKER

Edited text of question
Avatar of its_ajt

ASKER

Edited text of question
call PrintListbox(list1, true) to print all
call PrintListbox(list1, true) to print only selected

Private Sub PrintListBox(ByVal list As listbox, Optional ByVal fAll As Boolean = True)
    Dim i As Integer
    For i = 0 To list.ListCount - 1
        If (list.Selected(i) Or fAll) Then
            Printer.Print list.list(i)
        End If
    Next
    Printer.EndDoc
End Sub

call PrintListbox(list1, false) to print only selected
I was wondering how two *identical* calls were producing different results! (grin) For a moment there I thought you'ld invented the "do what I meant" function!

M
It's magic..
Avatar of its_ajt

ASKER

Can't get the code to work properly - something about list.Selected(i) being an invalid array but the programs at home and I'm at work! - and also it doesn't cater for multiple pages...........else I need more help getting it to work with the Printer object/Common dialog Control.

Thanks - Merry Xmas
Good Luck
ASKER CERTIFIED SOLUTION
Avatar of twolff
twolff

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial