这是vb.net。
Public GS As String = Chr(&H1D)
Public Function getBarcodeStr(ByVal msg As String) As String
getBarcodeStr = GS & "h" & Chr(80) 'Bardcode Hieght
getBarcodeStr = getBarcodeStr & GS & "w" & Chr(1) 'Barcode Width
getBarcodeStr = getBarcodeStr & GS & "f" & Chr(0) 'Font for HRI characters
getBarcodeStr = getBarcodeStr & GS & "H" & Chr(2) 'Position of HRI characters
getBarcodeStr = getBarcodeStr & GS & "k" & Chr(69) & Chr(20) 'Print Barcode Smb 39
getBarcodeStr = getBarcodeStr & msg & Chr(0) & vbCrLf 'Print Text Under
getBarcodeStr = getBarcodeStr & GS & "d" & Chr(3) & vbCrLf
getBarcodeStr = getBarcodeStr & GS & "@"
Return getBarcodeStr
End Function
Public Sub EPOSPrinter(ByVal PrintString As String)
RawPrinterHelper.SendStringToPrinter(My.Settings.PrinterName, PrintString)
End Sub
PrintString = getBarcodeStr("8714789570945") + vbCrLf 'Test this barcode
EPOSPrinter(PrintString)