Home All Groups Group Topic Archive Search About

Send raw data to a printer with VB .NET 2005?

Author
13 Feb 2006 7:13 PM
pete
Does anyone have a working example of sending raw data to a printer with
VB.NET 2005? I've tried this example
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vb05legacyhardware.asp
and got an error when trying to run it. The example listed above is close to
what I want to do, except I would like to send the data that is created on
the fly to the printer without using temporary files.

Thanks for your help,
Pete

Author
13 Feb 2006 7:28 PM
Chris
pete wrote:
> Does anyone have a working example of sending raw data to a printer with
> VB.NET 2005? I've tried this example
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vb05legacyhardware.asp
> and got an error when trying to run it. The example listed above is close to
> what I want to do, except I would like to send the data that is created on
> the fly to the printer without using temporary files.
>
> Thanks for your help,
> Pete
>
>

I used that example to get me started.  What error did you get?
Author
14 Feb 2006 3:08 AM
webserverpete
Chris wrote:
Show quoteHide quote
> pete wrote:
> > Does anyone have a working example of sending raw data to a printer with
> > VB.NET 2005? I've tried this example
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vb05legacyhardware.asp
> > and got an error when trying to run it. The example listed above is close to
> > what I want to do, except I would like to send the data that is created on
> > the fly to the printer without using temporary files.
> >
> > Thanks for your help,
> > Pete
> >
> >
>
> I used that example to get me started.  What error did you get?

I get the following error when I trun to run the program

Error    1    Handles clause requires a WithEvents variable defined in the
containing type or one of its base types.

It's complaining about this line

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
    ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Author
13 Feb 2006 8:12 PM
ernesth
Look at this link:

http://support.microsoft.com/kb/322090/en-us

Regards

Ernesto


pete wrote:
Show quoteHide quote
> Does anyone have a working example of sending raw data to a printer with
> VB.NET 2005? I've tried this example
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vb05legacyhardware.asp
> and got an error when trying to run it. The example listed above is close to
> what I want to do, except I would like to send the data that is created on
> the fly to the printer without using temporary files.
>
> Thanks for your help,
> Pete
Author
14 Feb 2006 3:10 AM
webserverpete
When I tried the example that you pointed out to me I get the following
errors

Warning    1    Variable 'di' is passed by reference before it has been
assigned a value. A null reference exception could result at runtime.
Make sure the structure or all the reference members are initialized
before use
Warning    2    Function 'SendStringToPrinter' doesn't return a value on all
code paths. A null reference exception could occur at run time when the
result is used.
Warning    3    Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.
Warning    4    Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be
evaluated.


I noticed that the article is for Dot Net 1.0 and Dot Net 1.1 but VB
2005 using Dot Net 2