我如何将下面的代码转换成java



这是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)

也许在不知道其他函数做什么的情况下试试这个:

public String getBarcodeStr(String msg){        
String getBarcodeStr = GS + "h" + Chr(80); //Bardcode Hieght";
        getBarcodeStr += GS + "w" + Chr(1);// 'Barcode Width
        getBarcodeStr += GS + "f" + Chr(0);// 'Font for HRI characters
        getBarcodeStr += GS + "H" + Chr(2);// 'Position of HRI characters
        getBarcodeStr += GS + "k" + Chr(69) + Chr(20);// 'Print Barcode Smb 39
        getBarcodeStr += msg + Chr(0)+ "n";// 'Print Text Under
        getBarcodeStr += GS + "d" & Chr(3) +"n";
        getBarcodeStr += GS + "@";
return getBarcodeStr;
}

相关内容

  • 没有找到相关文章

最新更新