Message 1 of 3
How print the contents of a list box?

Not applicable
08-18-2002
05:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've written a bit of code that goes off and does a search and then shows the results in a list box, but i'd also like to be able to print it out. Using the common dialog box control from comdlg32.ocx, i've ended up with the following, which i based on a VB6 program that used a rich text box:
Private Sub cmd_print_Click()
On Error Resume Next
With CommonDialog1
.CancelError = True
.DialogTitle = "Print Seach Results"
.PrinterDefault = True
.flags = cdlPDHidePrintToFile Or cdlPDNoPageNums Or cdlPDReturnDC
.flags = .flags Or cdlPDNoSelection
.ShowPrinter
If Err = 0 Then
' Print the entire contents of the text box
printer.Print lst_result.Text
End If
End With
End Sub
I end up with the print dialog showing OK, but nothing comes out. The rich text box program also had same format for printing, only it was printer.print richtextbox.text.
What do i need to do to get the contents printing out?
TIA.
Private Sub cmd_print_Click()
On Error Resume Next
With CommonDialog1
.CancelError = True
.DialogTitle = "Print Seach Results"
.PrinterDefault = True
.flags = cdlPDHidePrintToFile Or cdlPDNoPageNums Or cdlPDReturnDC
.flags = .flags Or cdlPDNoSelection
.ShowPrinter
If Err = 0 Then
' Print the entire contents of the text box
printer.Print lst_result.Text
End If
End With
End Sub
I end up with the print dialog showing OK, but nothing comes out. The rich text box program also had same format for printing, only it was printer.print richtextbox.text.
What do i need to do to get the contents printing out?
TIA.