返回列表 上一主題 發帖

[發問] VB.NET 印表機設定問題

[發問] VB.NET 印表機設定問題

  1. Public Class myPrinter
  2.    Friend TextToBePrinted As String
  3.    Public Sub prt(ByVal text As String)
  4.       TextToBePrinted = text
  5.       Dim prn As New Printing.PrintDocument
  6.       Using (prn)
  7.          prn.PrinterSettings.PrinterName = "PrinterName"
  8.          AddHandler prn.PrintPage,
  9.             AddressOf Me.PrintPageHandler
  10.          prn.Print()
  11.          RemoveHandler prn.PrintPage,
  12.             AddressOf Me.PrintPageHandler
  13.       End Using
  14.    End Sub
  15.    Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
  16.       Dim myFont As New Font("Microsoft San Serif", 10)
  17.          args.Graphics.DrawString(TextToBePrinted, New Font(myFont, FontStyle.Regular), Brushes.Black, 50, 50)
  18.    End Sub
  19. End Class
複製代碼
想請問我應該如何才能把
prn.PrinterSettings.PrinterName = "PrinterName"
改成
prn.PrinterSettings.PrinterName = TextBox1.Text
常試了改但都是錯誤未宣告?

        靜思自在 : 君子為目標,小人為目的。
返回列表 上一主題