Home All Groups Group Topic Archive Search About

Printing the contents of a textbox

Author
4 Apr 2006 10:35 AM
Jonathan Smith
In VB i had some very very simple code that would print out the contents of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???

Author
4 Apr 2006 12:08 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Jonathan Smith" <JonathanSm***@discussions.microsoft.com> schrieb:
> In VB i had some very very simple code that would print out the contents
> of a
> textbox for me.
>
> It was simply
>
> Sub PrintTB()
> Printer.Print(Text1.Text)
> End sub
>
> Very simple, and 110% effective.
>
> How the hell do i do this in VB .Net???

That's not as easy.  You will have to use the 'PrintDocument' object and
draw the string onto the printer using 'e.Graphics.ToString' in the
'PrintDocument''s 'PrintPage' event handler.  'PrintDocument' won't to
paging automatically, so you'll have to measure the text you are printing
and start a new page using 'e.HasMorePages' manually, which will cause
'PrintPage' to be called one more time for the next page.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
4 Apr 2006 12:24 PM
Jonathan Smith
Are you serious????

All i want to do is print the contents of a textbox

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Jonathan Smith" <JonathanSm***@discussions.microsoft.com> schrieb:
> > In VB i had some very very simple code that would print out the contents
> > of a
> > textbox for me.
> >
> > It was simply
> >
> > Sub PrintTB()
> > Printer.Print(Text1.Text)
> > End sub
> >
> > Very simple, and 110% effective.
> >
> > How the hell do i do this in VB .Net???
>
> That's not as easy.  You will have to use the 'PrintDocument' object and
> draw the string onto the printer using 'e.Graphics.ToString' in the
> 'PrintDocument''s 'PrintPage' event handler.  'PrintDocument' won't to
> paging automatically, so you'll have to measure the text you are printing
> and start a new page using 'e.HasMorePages' manually, which will cause
> 'PrintPage' to be called one more time for the next page.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
>
Author
4 Apr 2006 12:37 PM
Herfried K. Wagner [MVP]
"Jonathan Smith" <JonathanSm***@discussions.microsoft.com> schrieb:
> Are you serious????

Yes, I am.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
10 Apr 2006 4:39 AM
Homer J Simpson
"Jonathan Smith" <JonathanSm***@discussions.microsoft.com> wrote in message
news:D788E7CB-19EE-4834-8C08-E29E5160E2E0@microsoft.com...

> Are you serious????
>
> All i want to do is print the contents of a textbox

There's a really good run down of how do this in "Visual Basic 2005 Express
Edition for Dummies 2005", CHAPTER 9

Hint:
http://www.dummies.com/WileyCDA/DummiesTitle/productCd-0764597051,page-1.html
Author
4 Apr 2006 2:32 PM
Kerry Moorman
Jonathan,

The .Net framework includes classes that allow you to build sophisticated
print capabilities into an app.

But something as simple as the VB6 Printer object is not included.

You can google for .Net printing and find several third-party tools that
attempt to give you capabilities similar to the VB6 Printer object. I have
not tried these tools so I can't recommend any of them.

Kerry Moorman


Show quoteHide quote
"Jonathan Smith" wrote:

> In VB i had some very very simple code that would print out the contents of a
> textbox for me.
>
> It was simply
>
> Sub PrintTB()
> Printer.Print(Text1.Text)
> End sub
>
> Very simple, and 110% effective.
>
> How the hell do i do this in VB .Net???
Author
4 Apr 2006 4:16 PM
Aziz
perhaps this is what you mean?

Debug.Writeline("Hello")
Author
4 Apr 2006 11:07 PM
james
That won't print to the printer like he wishes to do.
james

Show quoteHide quote
"Aziz" <aziz***@googlemail.com> wrote in message
news:1144167373.141778.8610@u72g2000cwu.googlegroups.com...
> perhaps this is what you mean?
>
> Debug.Writeline("Hello")
>