Public Class Form1 Private Sub Form1_Load (sender as System.Object, E as System.EventArgs) Handles MyBase.Load Op Enfiledialog1.showdialog () TextBox1.Text = Openfiledialog1.filename ' Printdocument1.print () Print () End Sub Private Sub printdocument1_printpage (sender as System.Object, E as System.Drawing.Printing.Pr Intpageeventargs) Handles printdocument1.printpage e.graphics.drawstring (TextBox1.Text, New Font ("Arial"), New Pen (Color.Black, 1). Brush, E.graphics.fillrectangle (Brushes.blue, New Rectangle (p, p, max)) End Sub Sub Rint () Dim printdialog1 as New PrintDialog () ' PrintDialog1. ShowDialog () ' PrintDocument1 = OpenFileDialog1.FileName.ToString printdialog1.document = PrintDocument1 Dim Rusult as DialogResult = PrintDialog1. ShowDialog () If Rusult = DialogResult.OK then Printdocument1.print () End If End SubEnd Class
vb.net print the specified file-(currently the print file name)