Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Create a form in visual basic and add a Button and a PrintDocument controls from the tool
box.
Add the following declaration below Public Class Form1 line
Dim TextToPrint As String = ""
Add the following form load event code. Change the printer name to your printer name. To
find your printer name simply go to Control Panel, Devices and Printers, then find your
printer:
'Tax Amount
StringToPrint = "Tax
" & FormatCurrency("0.05", , , TriState.True, TriState.True) 'Change
to tax amount
LineLen = globalLengt
Dim spcLen6 As New String(" "c, Math.Round((26 - LineLen)))
If Not StringToPrint = "Tax
$0.00" Then
TextToPrint &= spcLen6 & StringToPrint & Environment.NewLine
End If
'Total Amount
StringToPrint = "Total
" & "$4.04"
LineLen = globalLengt
Dim spcLen8 As New String(" "c, Math.Round((26 - LineLen)))
TextToPrint &= spcLen8 & StringToPrint & Environment.NewLine & Environment.NewLine
'Cash Entered Amount
StringToPrint = "Cash
" & FormatCurrency("5.00", , , TriState.True, TriState.True)
LineLen = globalLengt
Dim spcLen9 As New String(" "c, Math.Round((26 - LineLen)))
If Not StringToPrint = "Cash
$0.00" Then
TextToPrint &= spcLen9 & StringToPrint & Environment.NewLine
End If
'Change Amount
StringToPrint = "Change
" & FormatCurrency("0.96", , , TriState.True, TriState.True)
LineLen = globalLengt
Dim spcLen10 As New String(" "c, Math.Round((26 - LineLen)))
TextToPrint &= Environment.NewLine & spcLen10 & StringToPrint & Environment.NewLine
End Sub
To print this sample receipt paper we just created add the following button click event to
call the methods we created earlier.