How can I print from Visual Basic

Asked By 10 points N/A Posted on -
qa-featured

Assume I am using a command tab and a text box. I want to be able to print the text  when I click the command button. How do I code this?

SHARE
Best Answer by Tom Smith
Best Answer
Best Answer
Answered By 0 points N/A #117977

How can I print from Visual Basic

qa-featured

Printing from Visual Basic requires passing two reports form “DoCmd.SelectObject “and “DoCmd.PrintOut “. Here is an example :

Create an object  “text1” and a command button. Go to Visual Basic's command pad and write the following : 

Private Sub Form_Load()

Printer.Print " This is my First visual basic work "
Printer.Print ""
Printer.Print " I love my work"
Printer.Print & Text1.Text &

Printer.EndDoc

End Sub

Answered By 0 points N/A #117978

How can I print from Visual Basic

qa-featured

1. Assume a text box named Text1

2. Assume a command Button named Command1

3. Double click Command1

3. Write the following code

Printer.CurrentX = Printer.ScaleWidth / 2
Printer.CurrentY = Printer.ScaleHeight / 2
Printer.Print Text1.Text
Printer.EndDoc
 

4.  Run the program and click Command1

Login/Register to Answer

Related Questions