Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

USB printing in VB6

223 views
Skip to first unread message

JimB417

unread,
Jul 27, 2001, 5:34:44 PM7/27/01
to
Greetings to all,

Can anyone tell me how to get my HP USB printer to work with VB6. I have an
old app that works great when using printers connected to the parallel port
(LPT1). There doesn't seem to be any useful info in MSDN help. I've tried using
the Printer object but to no avail. Thanks for any and all help.
Jim

Terry & Utahna

unread,
Jul 27, 2001, 6:27:24 PM7/27/01
to
Have you tried calling the CommonDialog1.ShowPrinter method? There you tell
your program what printer to use when printing...then use the printer
object... I have a HP LJ6 on LPT1, and Xerox Xk35c on USB1, and they work
great from my VB progs...


"JimB417" <jim...@aol.com> wrote in message
news:20010727173444...@ng-fb1.aol.com...

Guido Coenen

unread,
Jul 27, 2001, 6:47:06 PM7/27/01
to
Hi Jim,

what exactly is the problem? How does your old application print?
Sounds like it prints directly to LPT1:

VB6 uses the Windows printer model, which means it doesn't matter what
physical port the hardware is connected to - it's the driver's
business to know where to print to, your app shouldn't care for it.
But you have to use the printer object to get these benefits. Directly
printing to LPT1 means, the app doesn't use the driver and therefore
cannot access USB printers. Sounds like a case of bad programming.

Good luck,
Guido.

Michael Williams

unread,
Jul 27, 2001, 11:47:03 PM7/27/01
to
It's life, Jim, but not as we know it!

It sounds like your old "app" is as daft as a brush and expects all printers
to be connected to LPT1. How sad! Write another app that does the job
properly. The VB Printer Object will work fine with all printers, however
they are attached.

Mike


"JimB417" <jim...@aol.com> wrote in message
news:20010727173444...@ng-fb1.aol.com...

JimB417

unread,
Jul 27, 2001, 11:51:26 PM7/27/01
to
Guido wrote:>Hi Jim,

>
>what exactly is the problem? How does your old application print?
>Sounds like it prints directly to LPT1:
>
>VB6 uses the Windows printer model, which means it doesn't matter what
>physical port the hardware is connected to - it's the driver's
>business to know where to print to, your app shouldn't care for it.
>But you have to use the printer object to get these benefits. Directly
>printing to LPT1 means, the app doesn't use the driver and therefore
>cannot access USB printers. Sounds like a case of bad programming.
>
>Good luck,
>Guido.
>

That's what it does alright, the code in question is in part:

Open "LPT1" for Output as #1
For intX = 1 to 25
Print #1: Data(intX)
....
etc.

Is there any way to make this work with
USB or is this a lost cause.

P.S. your right this is not good programming, but it was written in VB3
and I have been away from VB programming for some time and I'm just
getting back into the game. Thanks for your help.
Jim

Michael Williams

unread,
Jul 28, 2001, 12:35:43 AM7/28/01
to
I think you really should use the standard VB Printer Object methods or,
alternatively, the various API printing functions. What is it, exactly, that
requires you to print directly to LPT1? If you really want to stick with
that "direct" merthod then there is one thing you could try (although I
don't know whether it would work with USB ports):

Open Printer.Port for Output as 1
For IntX = 1 to 25
Print #1 . . . . .
etc
etc

Mike

"JimB417" <jim...@aol.com> wrote in message

news:20010727235126...@ng-dd1.aol.com...

Larry Linson

unread,
Jul 28, 2001, 12:54:08 AM7/28/01
to
I'm not even sure an individual app can access system ports in Windows NT,
2K, ME, and XP.

"Michael Williams" <Mi...@peetsmill.freeserve.co.uk> wrote in message
news:9jtfk4$v1e$1...@newsg2.svr.pol.co.uk...


> I think you really should use the standard VB Printer Object methods or,
> alternatively, the various API printing functions. What is it, exactly,
that

> requires you to print directly to LPT1? . . .


Terry & Utahna

unread,
Jul 28, 2001, 2:29:36 AM7/28/01
to
Here's my printer code...works great for my Laserjet (LPT1) and my Xerox
(USB1)

CommonDialog1.CancelError = True
On Error GoTo ErrHandler 'This happens when user clicks "Cancel"
CommonDialog1.ShowPrinter
nc = CommonDialog1.Copies

For i = 0 To Printer.FontCount - 1 'I want to print in a monospaced
font...
If InStr(Printer.Fonts(i), "Fixedsys") Or InStr(Printer.Fonts(i),
"Terminal") Or _
InStr(Printer.Fonts(i), "Letter Gothic") Then
Printer.Font = Printer.Fonts(i)
Exit For
End If
Next

Printer.FontSize = 12
Printer.FontBold = True
Printer.FontUnderline = True
Printer.FontItalic = False

x$ = "lotsa stuff to print"

for i=1 to nc 'how many copies you need?
Printer.Print x$
printer.EndDoc
next

JimB417

unread,
Jul 28, 2001, 6:34:12 PM7/28/01
to
Terry & Utahna wrote:

>Here's my printer code...works great for my Laserjet (LPT1) and my Xerox
>(USB1)
>
>CommonDialog1.CancelError = True
> On Error GoTo ErrHandler 'This happens when user clicks "Cancel"
> CommonDialog1.ShowPrinter
> nc = CommonDialog1.Copies
>
> For i = 0 To Printer.FontCount - 1 'I want to print in a monospaced
>font...
> If InStr(Printer.Fonts(i), "Fixedsys") Or InStr(Printer.Fonts(i

Thanks, guys and to Michael and Larry for all your help. I will give your ideas
a whirl.
Jim

Guido Coenen

unread,
Jul 28, 2001, 6:49:19 PM7/28/01
to
Hi Jim,

this will never work with USB devices.
You have to redesign your program for use with the windows printer
driver, like replacing your "Print #1" - statements with Printer.Print
and such.

By the way, there could be another problem with modern printers even
if they were connected to LPT1: Cheap printers are GDI printers, which
means the printer is dumb as a nut and all printing is actually done
by the windows driver. The driver renders complete pages and gives
them to the printer. Printing directly to the printer port doesn't
print too much on these printers.

Good luck,
Guido.

On 28 Jul 2001 03:51:26 GMT, jim...@aol.com (JimB417) wrote:

>>...


>
>That's what it does alright, the code in question is in part:
>
>Open "LPT1" for Output as #1
>For intX = 1 to 25
> Print #1: Data(intX)
>....
>etc.
>
>Is there any way to make this work with
>USB or is this a lost cause.

>...

Michael Williams

unread,
Jul 28, 2001, 11:14:55 PM7/28/01
to
"Guido Coenen" <guido....@d.kamp.net> wrote in message
news:3b633659...@news.kamp.net...

> By the way, there could be another problem with modern printers even
> if they were connected to LPT1: Cheap printers are GDI printers, which
> means the printer is dumb as a nut and all printing is actually done
> by the windows driver. The driver renders complete pages and gives
> them to the printer. Printing directly to the printer port doesn't
> print too much on these printers.

Lots of "not so cheap" printers are, too! Virtually all of the HP DeskJet
range, for example, even the most expensive models.

Mike


0 new messages