Printing text from a text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • badboylee17
    New Member
    • Sep 2007
    • 2

    Printing text from a text box

    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
    Contributor
    • Sep 2007
    • 471

    #2
    there is no such method in vb.net

    check this link out for help printning in vb.net

    Comment

    • shrimant
      New Member
      • Sep 2007
      • 48

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

      Code:
      Private Sub Command1_Click()
          Printer.Print (Text1.Text)
          DoEvents
      End Sub
      Regards
      -Shrimant Patel-
      [link removed]
      Last edited by MMcCarthy; Sep 27 '07, 08:09 AM. Reason: link removed - against site rules

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        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.

        Comment

        • Ali Rizwan
          Banned
          Contributor
          • Aug 2007
          • 931

          #5
          Originally posted by badboylee17
          I am trying to print the contents of a textbox ...
          Hello,
          Use these lines

          [CODE=vb]Private Sub Command1_Click( )
          Text1.Font.Name = "Arial"
          Text1.Font.Size = 10
          Text1.Text = "Hello World"
          PrintForm
          End Sub[/CODE]

          and for your second question use Killer's EndDoc command.

          Comment

          Working...