📄 machine.bas
字号:
Attribute VB_Name = "Machine"
Option Explicit
Global hPrinter As Long
Public Function Print_ICCID(pICCID As String, PrintType As Integer) As Boolean
Dim bRc As Long
Dim lPrinterACKTimeout As Long
Dim bReject As Boolean
Dim s As String
lPrinterACKTimeout = 5000
Call NBSClearBuffer(hPrinter)
bRc = NBSSCWaitEnquiry(hPrinter, lPrinterACKTimeout)
If bRc = 1 Then
Select Case PrintType
Case 0
bRc = NBSPrintLayout(hPrinter, "XIAO")
s = Mid(pICCID, 1, 5) + vbCrLf + _
Mid(pICCID, 6, 5) + vbCrLf + _
Mid(pICCID, 11, 5) + vbCrLf + _
Mid(pICCID, 16, 5) + vbCrLf
Case 1
bRc = NBSPrintLayout(hPrinter, "DAKA")
s = pICCID + vbCrLf
Case 2
bRc = NBSPrintLayout(hPrinter, "DAKA")
s = pICCID + vbCrLf + _
Mid(pICCID, 1, 5) + vbCrLf + _
Mid(pICCID, 6, 5) + vbCrLf + _
Mid(pICCID, 11, 5) + vbCrLf + _
Mid(pICCID, 16, 5) + vbCrLf
Case 3
bRc = NBSPrintLayout(hPrinter, "ST")
s = Mid(pICCID, 1, 5) + vbCrLf + _
Mid(pICCID, 6, 5) + vbCrLf + _
Mid(pICCID, 11, 5) + vbCrLf + _
Mid(pICCID, 16, 5) + vbCrLf + _
mMSISDN + vbCrLf
End Select
bRc = NBSPrintCard(hPrinter, s, Len(s), bReject)
If (bRc = 1) Then
bRc = NBSSCWaitResponse(hPrinter, lPrinterACKTimeout)
End If
End If
If bRc = 1 Then
Print_ICCID = True
Else
Print_ICCID = False
End If
End Function
'设备进卡函数
Function InputCard() As Long
Dim bRc As Long
Dim lPrinterACKTimeout As Long
lPrinterACKTimeout = 5000
Call NBSClearBuffer(hPrinter)
bRc = NBSSCWaitEnquiry(hPrinter, lPrinterACKTimeout)
If (bRc = 1) Then
bRc = NBSSCPick(hPrinter)
If (bRc = 1) Then
bRc = NBSSCWaitACK(hPrinter, lPrinterACKTimeout, WAIT_1_ACK)
If (bRc = 1) Then
bRc = NBSSCWaitResponse(hPrinter, lPrinterACKTimeout)
End If
End If
End If
Delay (300)
If (bRc = 1) Then
InputCard = 0
Else
InputCard = 1001
End If
End Function
'丢废卡
Public Function RejectCard() As Long
Dim bRc As Long
Dim lPrinterACKTimeout As Long
lPrinterACKTimeout = 5000
bRc = NBSSCReject(hPrinter)
NBSClearBuffer (hPrinter)
If (bRc = 1) Then
bRc = NBSSCWaitACK(hPrinter, lPrinterACKTimeout, WAIT_1_ACK)
End If
If (bRc = 1) Then
bRc = NBSSCWaitResponse(hPrinter, lPrinterACKTimeout)
End If
Delay (1000)
If (bRc = 1) Then
RejectCard = 0
Else
RejectCard = 1001
End If
End Function
'正常出卡
Public Function StackCard() As Long
Dim bRc As Long
Dim lPrinterACKTimeout As Long
lPrinterACKTimeout = 55000
bRc = NBSSCAccept(hPrinter)
NBSClearBuffer (hPrinter)
If (bRc = 1) Then
bRc = NBSSCWaitACK(hPrinter, lPrinterACKTimeout, WAIT_1_ACK)
End If
If (bRc = 1) Then
bRc = NBSSCWaitResponse(hPrinter, lPrinterACKTimeout)
End If
Delay (500)
If (bRc = 1) Then
StackCard = 0
Else
StackCard = 1001
End If
End Function
Function ResetMachine() As Long
End Function
Public Sub OpenNBSPrinter()
Dim bRc As Long
Dim strCommPort As String
Dim lCommBaudRate As Long
strCommPort = "COM1" + Chr$(&H0)
lCommBaudRate = 115200
bRc = NBSSCOpen(strCommPort, lCommBaudRate, hPrinter)
If bRc <> 1 Then
bRc = MsgBox("打开发卡机端口失败!" + vbCrLf + "确定要重新启动系统吗?", vbYesNo + vbQuestion + vbDefaultButton2, "提示")
If bRc = vbYes Then
ExitWindowsEx &H43, 0
Else
Exit Sub
End If
End If
End Sub
Public Sub CloseNBSPrinter()
NBSSCClose (hPrinter)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -