Connecting Tech Pros Worldwide Forums | Help | Site Map

Printing text from a text box

Newbie
 
Join Date: Sep 2007
Posts: 2
#1: Sep 26 '07
I am trying to print the contents of a textbox using the following piece of code:
Printer.Print Text1.Text

Although I have come across 2 problems,

1. I want to print it out in the same font and size that is displayed in the box.

2. I want it to print immediately but atm it only prints when I close the program.

Help please.

Many thanks.
Lee

jamesd0142's Avatar
Needs Regular Fix
 
Join Date: Sep 2007
Location: Wales
Posts: 467
#2: Sep 26 '07

re: Printing text from a text box


there is no such method in vb.net

check this link out for help printning in vb.net

http://visualbasic.about.com/od/usin...rintvb2005.htm
Member
 
Join Date: Sep 2007
Posts: 50
#3: Sep 26 '07

re: Printing text from a text box


Assuming I have textbox named Text1 and a Command Button named Command1:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Printer.Print (Text1.Text)
  3.     DoEvents
  4. End Sub
Regards
-Shrimant Patel-
[link removed]
Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#4: Sep 26 '07

re: Printing text from a text box


We don't actually know what version of VB this is about.

In VB6, both can be easily addresed by setting the font properties of the Printer object to match those of the textbox, and following up with Printer.EndDoc.
Ali Rizwan's Avatar
Banned
 
Join Date: Aug 2007
Location: Lahore Pakistan
Posts: 929
#5: Sep 27 '07

re: Printing text from a text box


Quote:

Originally Posted by badboylee17

I am trying to print the contents of a textbox ...

Hello,
Use these lines

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Text1.Font.Name = "Arial"
  3. Text1.Font.Size = 10
  4. Text1.Text = "Hello World"
  5. PrintForm
  6. End Sub
and for your second question use Killer's EndDoc command.
Reply