Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21271

ListView printout mess-up, please help

$
0
0
Code:

Private Sub cmdPrint_Click()

Dim i As Long
Dim Count As Integer
Count = 1

    Printer.FontName = "courier new" 'Monospaced font works best
    Printer.FontSize = 5
    Printer.PaperSize = vbPRPSLetter 'Short bond paper size, 8.5" x 11"
    Printer.Orientation = vbPRORLandscape
    Printer.FontUnderline = False
    Printer.Print
    PrintAlignedText "Republic of the Philippines", vbCenter
    Printer.Print
    PrintAlignedText "Malolos City", vbCenter
    Printer.Print
    PrintAlignedText "Automated Traffic Violation Ticket Encoding System", vbCenter
    Printer.Print
    Printer.Print
    Printer.FontUnderline = True 'Printing column headers
    Printer.Print "No"; _
                  Tab(6); "TicketNumber"; _
                  Tab(28); "LastName"; _
                  Tab(48); "FirstName"; _
                  Tab(68); "MiddleName"; _
                  Tab(88); "Violation"; _
                  Tab(128); "PlateNumber"; _
                  Tab(148); "LicenseNumber"; _
                  Tab(168); "DateCommitted"; _
                  Tab(182); "TimeCommitted"; _
                  Tab(202); "PlaceCommitted"; _
                  Tab(224); "Officer"; _

    Printer.FontUnderline = False
    For i = 1 To lvwViolator.ListItems.Count
    If lvwViolator.ListItems(i).Checked = True Then
        Printer.Print Count; _
                      Tab(6); lvwViolator.ListItems(i); _
                      Tab(28); lvwViolator.ListItems(i).ListSubItems(1); _
                      Tab(48); lvwViolator.ListItems(i).ListSubItems(2); _
                      Tab(68); lvwViolator.ListItems(i).ListSubItems(3); _
                      Tab(88); lvwViolator.ListItems(i).ListSubItems(4); _
                      Tab(128); lvwViolator.ListItems(i).ListSubItems(5); _
                      Tab(148); lvwViolator.ListItems(i).ListSubItems(6); _
                      Tab(168); lvwViolator.ListItems(i).ListSubItems(7); _
                      Tab(182); lvwViolator.ListItems(i).ListSubItems(8); _
                      Tab(202); lvwViolator.ListItems(i).ListSubItems(9); _
                      Tab(224); lvwViolator.ListItems(i).ListSubItems(10); _
                      Count = Count + 1
    End If
    Next
    Printer.EndDoc
   
End Sub

On the printout the headings and ListView records display correctly, except that the record count generated by the search function (not shown), identified by the Count variable, is always stuck at 1 instead of incrementing. The instance of the Count variable in the first record is not in its correct place but was moved to the right of the "Officer" heading. And the word "False" is always displayed to the right of each value of the "Officer" field.

Viewing all articles
Browse latest Browse all 21271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>