-
How do you print the contents of a list box?
I would be very grateful if someone could recommend some code which would allow me to print the contents of a listbox in VB6. I would ideally like to call the standard ‘print dialog box’, however this is not vital.
One big complication could involve the fact that I am populating my listbox ‘lst_Bookings’ using the following subroutine:
[I]Sub DisplayBookings(e)
'The value 'b' is defined as an integer
Dim b As Integer
'BookingData is defined as a string
Dim BookingData As String
'The bookings list is cleared so that only the records for the appropriate event are displayed
lst_Bookings.Clear
Code:
For b = 1 To BookingCount
With Booking(b)
'If the 'Event_ID' value = to 'e' the booking data is displayed in the list box
If .Event_ID = e Then
BookingData = .Ticket_No & " " & .Student_ID & " " & .Booking_Date
'The booking data is added to the list box
lst_Bookings.AddItem BookingData
End If
End With
Next b
This is due to the fact that my data is being stored in a file, not an array, and also because a combo box selection is determining what information is displayed. All my variables are defined in a module, as they need to be used by more than one program.
Thanks!
-
It really doesn't matter how the listbox is populated.
After it is, this will print it
Code:
Private Sub Command1Click()
Dim i As Long
For i = 0 To List1.ListCount - 1
Printer.Print List1.List(i)
Next
Printer.EndDoc
End Sub
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Thanks for the code, it works a treat! 
Is there any way I could combine it with the print dialog box so that the user could choose a printer?
-
Put a common dialog control on the form.
Code:
Private Sub Command1_Click()
On Error GoTo ErrTrap
Dim i As Long
With CommonDialog1
.DialogTitle = "Page Setup"
.CancelError = True
.ShowPrinter
End With
For i = 0 To List1.ListCount - 1
Printer.Print List1.List(i)
Next
Printer.EndDoc
Exit Sub
ErrTrap:
If Err.Number = 32755 Then
MsgBox "Print Job Cancelled."
End If
End Sub
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
VB crashes when I try to load the 'common dialog' control onto my toolbar.
-
Well, thats a first for me.
What happens? What does "crashes" mean?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
I don’t currently have the ‘Common Dialog’ Control loaded on my toolbox. In order to add it, I am selecting my toolbox by right clicking, navigating to ‘components’, before selecting the ‘Microsoft Common Dialog Control 6.0’ on the list of controls. When I then click ‘Apply’, VB comes up with an error which reads: ‘Visual Basic has encountered a problem and needs to close. We are sorry for the inconvenience.’ The program then crashes.
-
What version of VB6 are you using?
Are you up to date on the service packs?
Did your VB6 get installed from a valid, factory, Visual Basic CD?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
VB6 Enterprise Edition, version 8176; I’m using a college library machine, so I haven’t got the access rights to install anything.
(Actually, the library is closing now, so I’ll be back on the forum again tomorrow.)
Many thanks for your time and help!
-
Then you need to report this issue to the folks in charge of maintaining the Library computers.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Ok, will do that. Thanks anyway!
-
Try a different computer in the Library...it may be just a problem with the VB on that one individual machine.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
By admol in forum ASP.NET
Replies: 1
Last Post: 03-09-2007, 09:44 AM
-
By Scott in forum ASP.NET
Replies: 1
Last Post: 12-19-2001, 02:12 AM
-
By BirdsOfFire in forum VB Classic
Replies: 0
Last Post: 08-02-2001, 09:37 PM
-
By John in forum VB Classic
Replies: 0
Last Post: 03-19-2001, 09:53 PM
-
Replies: 2
Last Post: 03-24-2000, 01:05 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks