How can I print from Visual Basic
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?
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?
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
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