ESC POS Uyumlu Yazıcılar İçin Örnek Kod

Seri port uzerinde esc pos cihazda çıktı almak için kullanılan kodlar…

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sp.WriteLine(“doğan dağelen”)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Try
If Not sp.IsOpen Then
sp.Encoding = System.Text.Encoding.GetEncoding(857)
sp.Open()
Dim komut1() As Byte = {27, 40}
sp.Write(komut1, 0, komut1.Length)
End If
Catch ex As Exception

End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
‘Select print mode
Dim komut() As Byte = {29, 33, 0}
sp.Write(komut, 0, komut.Length)
‘Set alignment
Dim komut1() As Byte = {27, 97, 1}
sp.Write(komut1, 0, komut1.Length)
‘Select barcode font
Dim komut2() As Byte = {29, 102, 0}
sp.Write(komut2, 0, komut2.Length)
‘Sets the position of where you want to print the barcode text
Dim komut3() As Byte = {29, 72, 2}
sp.Write(komut3, 0, komut3.Length)
‘Sets the width of the barcode
Dim komut4() As Byte = {29, 119, 2}
sp.Write(komut4, 0, komut4.Length)
‘Sets the height of the barcode
Dim komut5() As Byte = {29, 104, 100}
sp.Write(komut5, 0, komut5.Length)
‘print barcode
Dim komutBarkod() As Byte = {29, 107, 69, 8, 48, 49, 50, 51, 52, 53, 54, 55}
sp.Write(komutBarkod, 0, komutBarkod.Length)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim kutu As String = “”
kutu = kutu + “┌────────┐” + vbCrLf
kutu = kutu + “│ │” + vbCrLf
kutu = kutu + “│ │” + vbCrLf
kutu = kutu + “│ │” + vbCrLf
kutu = kutu + “└────────┘” + vbCrLf
sp.Write(kutu)
kutu = “”
kutu = kutu + “╔════════╗” + vbCrLf
kutu = kutu + “║ ║” + vbCrLf
kutu = kutu + “║ ║” + vbCrLf
kutu = kutu + “║ ║” + vbCrLf
kutu = kutu + “╚════════╝” + vbCrLf
sp.Write(kutu)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim komut1() As Byte = {27, 77, 1}
sp.Write(komut1, 0, komut1.Length)
sp.WriteLine(“Font 27 x 77 x 1″)
Dim komut() As Byte = {27, 77, 0}
sp.Write(komut, 0, komut.Length)

Dim komutdw() As Byte = {29, 66, 1}
sp.Write(komutdw, 0, komutdw.Length)
sp.WriteLine(“29 x 66 x 1″)
Dim komutdw2() As Byte = {29, 66, 0}
sp.Write(komutdw2, 0, komutdw2.Length)
Dim komut2() As Byte = {27, 33, 17}
sp.Write(komut2, 0, komut2.Length)
sp.WriteLine(“27, 33, 17″)
Dim komut33() As Byte = {27, 33, 0}
sp.Write(komut33, 0, komut33.Length)
Dim komut3() As Byte = {27, 45, 2}
sp.Write(komut3, 0, komut3.Length)
sp.WriteLine(“27, 45, 2″)
Dim komut4() As Byte = {27, 45, 0}
sp.Write(komut4, 0, komut4.Length)
End Sub
End Class