问题描述
Hallo Friends
Hallo Friends
我有PDA Casio IT-600并希望通过蓝牙打印到Citizen CMP-30打印机。
I have a PDA Casio IT-600 and want print to a Citizen CMP-30 printer via bluetooth.
如果我使用以下代码打印,它可以正常工作:
If I print with following code, it works fine:
暗淡comPort1作为新的SerialPort(QUOT; COM6" ;, 57600,Parity.None,8,StopBits.One)
Dim comPort1 As New SerialPort("COM6", 57600, Parity.None, 8, StopBits.One)
       尝试
comPort1.Open()
C ex ex As Exception
MessageBox.Show(" BITTE schalten SIE书房德鲁克EIN奥德stellen SIE死蓝牙Verbindung WIEDER她的"!)
        &NBSP ;  退出Sub¥
结束尝试
Try
comPort1.Open()
Catch ex As Exception
MessageBox.Show("Bitte schalten Sie den Drucker ein oder stellen Sie die Bluetooth-Verbindung wieder her!")
Exit Sub
End Try
comPort1.WriteLine("!0 200 200 229 1")
comPort1.WriteLine(" T 7 0 30 02 Text1")
comPort1.WriteLine(" T 7 0 30 22 Text2")
comPort1.WriteLine(" PRINT")
comPort1.WriteLine("! 0 200 200 229 1")
comPort1.WriteLine("T 7 0 30 02 Text1")
comPort1.WriteLine("T 7 0 30 22 Text2")
comPort1.WriteLine("PRINT")
comPort1.Close()
comPort1.Close()
但如果我尝试使用如下代码之类的变量文本则不起作用:
But if I try to use an variable text like following code it doesn't works:
;    Dim comPort1 As New SerialPort("COM6",57600,Parity.None,8,StopBits.One)
Dim comPort1 As New SerialPort("COM6", 57600, Parity.None, 8, StopBits.One)
Dim text1 As String =" Text1"
Dim text2 As String =" Text2"
Dim text1 As String = "Text1"
Dim text2 As String = "Text2"
comPort1.WriteLine("!0 200 200 229 1")
comPort1.WriteLine(" T 7 0 30 02" + text1)
comPort1.WriteLine(" T 7 0 30 22" + text2)
comPort1.WriteLine(" PRINT")
comPort1.WriteLine("! 0 200 200 229 1")
comPort1.WriteLine("T 7 0 30 02" + text1)
comPort1.WriteLine("T 7 0 30 22" + text2)
comPort1.WriteLine("PRINT")
comPort1.Close()
comPort1.Close()
打印变量文本或条形码怎么办?
What have I to do to print variable text or barcode?
任何人都可以帮助我。
提前致谢
推荐答案
Writeline将执行"T 7 0 30 02" + text1 - > "T 7 0 30 02" +"Text1" - > "T 7 0 30 02Text1"你可能想要"T 7 0 30 02 Text1"
Writeline will do "T 7 0 30 02" + text1 --> "T 7 0 30 02" + "Text1" --> "T 7 0 30 02Text1" while you probably want "T 7 0 30 02 Text1"
$
编辑:
请参阅http://stackoverflow.com/questions/734600/the-difference-between-and-for-joining-strings-in-vb-net
See http://stackoverflow.com/questions/734600/the-difference-between-and-for-joining-strings-in-vb-net
在vb.net中最好使用&而不是+来连接字符串
In vb.net it might be better to use & instead of + to concatenate strings
这篇关于打印cpcl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!