VB打开POS机钱箱源码.
VB打开POS机钱箱,源码.使用VB的MSComm控件. Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdOpen_Click() Dim sTmp As String '打开钱箱命令 sTmp = Chr(2) & Chr(77) OpenBox sTmp End Sub Private Sub cmdOpen1_Click() Dim sTmp As String '打开钱箱命令chr(27)+chr(112)+chr(0)+chr(60)+chr(255) sTmp = Chr(27) & Chr(112) & Chr(0) & Chr(60) & Chr(255) OpenBox sTmp End Sub Private Sub Command1_Click() Dim sTmp As String sTmp = Chr(27) & Chr(57) & Chr(0) & Chr(60) & Chr(255) OpenBox sTmp End Sub Private Sub Form_Load() '显示最上层 SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next '显示最上层取消 SetWindowPos Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub OpenBox(PDStr As String) On Error GoTo OpenErr '------------使用 COMM控件时--------------------- Dim Instring As String ' 使用 COM1。 Comm1.CommPort = 1 ' 9600 波特,无奇偶校验,8 位数据,一个停止位。 Comm1.Settings = "9600,N,8,1" ' 当输入占用时, ' 告诉控件读入整个缓冲区。 Comm1.InputLen = 0 ' 打开端口。 Comm1.PortOpen = True '------------------------------------------------ Comm1.Output = PDStr Comm1.PortOpen = False Exit Sub OpenErr: MsgBox "钱箱端口打开错误:" & Err.Description, vbCritical Exit Sub End Sub & Chr(112) & Chr(0) & Chr(60) & Chr(255) OpenBox sTmp End Sub Private Sub Command1_Click() Dim sTmp As String sTmp = Chr(27) & Chr(57) & Chr(0) & Chr(60) & Chr(255) OpenBox sTmp End Sub Private Sub Form_Load() '显示最上层 SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next '显示最上层取消 SetWindowPos Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub OpenBox(PDStr As String) On Error GoTo OpenErr '------------使用 COMM控件时--------------------- Dim Instring As String ' 使用 COM1。 Comm1.CommPort = 1 ' 9600 波特,无奇偶校验,8 位数据,一个停止位。 Comm1.Settings = "9600,N,8,1" ' 当输入占用时, ' 告诉控件读入整个缓冲区。 Comm1.InputLen = 0 ' 打开端口。 Comm1.PortOpen = True '------------------------------------------------ Comm1.Output = PDStr Comm1.PortOpen = False Exit Sub OpenErr: MsgBox "钱箱端口打开错误:" & Err.Description, vbCritical Exit Sub End Sub
用户评论