Menu Horisontal

Sabtu, 05 Januari 2013

Sent a string to LPT1 VB.NET

Private textToPrint As String
Private Sub PrintSomeText(ByVal text As String)
        Dim pd As New Printing.PrintDocument()
        Dim pDialog As New PrintDialog()
        If pDialog.ShowDialog() = DialogResult.Cancel Then Exit Sub
        pd.PrinterSettings = pDialog.PrinterSettings
        AddHandler pd.PrintPage, AddressOf PrintDocument_Print
        textToPrint = text
        pd.Print()
End Sub

Private Sub PrintDocument_Print(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
    e.Graphics.DrawString(textToPrint, Me.Font, Brushes.Black, e.MarginBounds)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.PrintSomeText("Hello world, this is my text...")
End Sub
 
 

Tidak ada komentar: