关于读写: 写: Public Const gStrSTX As String = "02" '常量,包头 Public Const gStrETX As String = "03" '常量,包尾Private Sub Command2_Click()
Dim IntI As Integer Dim StrA As String
For IntI = 1 To Len(Text1) - 6 StrA = StrA & Asc(Mid(Text1, IntI, 1)) Next IntI ' StrA = StrA & Right(Text1, 6)
StrA = CreateWriteData(StrA)
Dim WriteBuf() As Byte Dim intH As Integer
intH = 0 'if Len(StrData)=156 then Buffer(0 to 155) Total:156 ReDim WriteBuf(Len(StrA) / 2 - 1) As Byte
'对数据逐一进行转换 For IntI = 1 To Len(StrA) Step 2
WriteBuf(intH) = "&H" & Mid$(StrA, IntI, 2)
intH = intH + 1 Next IntI
mLngS = HCE300_Write(HCE300_TRACK2, WriteBuf(0)) If mLngS = 0 Then
Else MsgBox FUN_ErrInfo(mLngS) Exit Sub End IfEnd SubPublic Function CreateWriteData(ByVal WriteData As String) As String Dim StrTemp As String
StrTemp = GetHexData(";2" & WriteData & "?")' 数据包加上包尾 StrTemp = StrTemp & gStrETX' 加上包头?加上校验位 StrTemp = gStrSTX & StrTemp '& GetLRC(strTemp) CreateWriteData = StrTemp End Function Public Function GetHexData(ByVal StrData As String) As String Dim StrTemp As String Dim IntI As Integer
'先得到每个字符的Ascii码,再将其Ascii码转换成十六进制
For IntI = 1 To Len(StrData) StrTemp = StrTemp & Hex(Asc(Mid$(StrData, IntI, 1))) Next IntI ' GetHexData = StrTemp End Function 读: Private Sub Command3_Click() Dim ReadBuf(36) As Byte Dim StrA As String Dim StrHexData As String
Dim IntI As Integer
Text2 = ""
mLngS = HCE300_Read(HCE300_TRACK2, ReadBuf(0)) If mLngS = 0 Then
StrHexData = ""
StrA = ""
For IntI = 3 To UBound(ReadBuf()) StrHexData = StrHexData & Chr(ReadBuf(IntI))
If IntI < 31 Then If IntI Mod 2 = 0 Then StrA = StrA & Chr(Mid(StrHexData, IntI - 3, 2))
End If End If Next
StrA = StrA & Right(StrHexData, 6) Text2 = StrA
Text3 = StrComp(Text1, Text2)
Else MsgBox FUN_ErrInfo(mLngS) Exit Sub End If 'VM4WDHYE31E482123456 'VM4WDHYE31E482123456End Sub Function FUN_ErrInfo(ByVal errCode As Integer) As String Select Case errCode Case 0 FUN_ErrInfo = "" Case -1 gBoolShowErr = True FUN_ErrInfo = "操作错误" Case -10 FUN_ErrInfo = "设备未打开" Case -11 FUN_ErrInfo = "设备已经打开" Case -12 gBoolShowErr = True FUN_ErrInfo = "读写器未联机" Case -13 gBoolShowErr = True FUN_ErrInfo = "错误的调用参数" Case -14 FUN_ErrInfo = "操作已超时" Case -15 FUN_ErrInfo = "用户中断" Case -16 FUN_ErrInfo = "ESC中断" Case -17 FUN_ErrInfo = "输入缓冲区为空" Case -100
学习
最近朋友样我开发一种校园IC卡的程序
事成之后报酬上万
怎么做呀?
有这方面材料的朋友联系我呀!
E-mail:[email protected]事成之后现金重谢!
如果可能的话,学校里的图书馆、理发馆、小卖部、澡池等都可以用,无非是网络联接问题及结算问题。
具体看需要,看学校要实现什么功能,现在这种程序有很多,在网上也能搜到。
没有的话,这就很难说了
最近朋友样我开发一种校园IC卡的程序
事成之后报酬上万
怎么做呀?
有这方面材料的朋友联系我呀!
E-mail:[email protected]
干脆我提供给你相关的软件
现在是程序经常莫名出错:
“vb6.exe 产生了错误,会被windows关闭。您需要重新启动程序。
正在创建错误日志。”
我觉得是用了读写器的函数有关,是不是因为打开设备后没关闭才出这个错误呢?
写:
Public Const gStrSTX As String = "02" '常量,包头
Public Const gStrETX As String = "03" '常量,包尾Private Sub Command2_Click()
Dim IntI As Integer
Dim StrA As String
For IntI = 1 To Len(Text1) - 6
StrA = StrA & Asc(Mid(Text1, IntI, 1))
Next IntI
'
StrA = StrA & Right(Text1, 6)
StrA = CreateWriteData(StrA)
Dim WriteBuf() As Byte
Dim intH As Integer
intH = 0
'if Len(StrData)=156 then Buffer(0 to 155) Total:156
ReDim WriteBuf(Len(StrA) / 2 - 1) As Byte
'对数据逐一进行转换
For IntI = 1 To Len(StrA) Step 2
WriteBuf(intH) = "&H" & Mid$(StrA, IntI, 2)
intH = intH + 1
Next IntI
mLngS = HCE300_Write(HCE300_TRACK2, WriteBuf(0)) If mLngS = 0 Then
Else
MsgBox FUN_ErrInfo(mLngS)
Exit Sub
End IfEnd SubPublic Function CreateWriteData(ByVal WriteData As String) As String
Dim StrTemp As String
StrTemp = GetHexData(";2" & WriteData & "?")' 数据包加上包尾
StrTemp = StrTemp & gStrETX' 加上包头?加上校验位
StrTemp = gStrSTX & StrTemp '& GetLRC(strTemp) CreateWriteData = StrTemp
End Function
Public Function GetHexData(ByVal StrData As String) As String
Dim StrTemp As String
Dim IntI As Integer
'先得到每个字符的Ascii码,再将其Ascii码转换成十六进制
For IntI = 1 To Len(StrData)
StrTemp = StrTemp & Hex(Asc(Mid$(StrData, IntI, 1)))
Next IntI
'
GetHexData = StrTemp
End Function
读:
Private Sub Command3_Click()
Dim ReadBuf(36) As Byte
Dim StrA As String
Dim StrHexData As String
Dim IntI As Integer
Text2 = ""
mLngS = HCE300_Read(HCE300_TRACK2, ReadBuf(0)) If mLngS = 0 Then
StrHexData = ""
StrA = ""
For IntI = 3 To UBound(ReadBuf()) StrHexData = StrHexData & Chr(ReadBuf(IntI))
If IntI < 31 Then
If IntI Mod 2 = 0 Then
StrA = StrA & Chr(Mid(StrHexData, IntI - 3, 2))
End If
End If
Next
StrA = StrA & Right(StrHexData, 6)
Text2 = StrA
Text3 = StrComp(Text1, Text2)
Else
MsgBox FUN_ErrInfo(mLngS)
Exit Sub
End If
'VM4WDHYE31E482123456
'VM4WDHYE31E482123456End Sub
Function FUN_ErrInfo(ByVal errCode As Integer) As String
Select Case errCode
Case 0
FUN_ErrInfo = ""
Case -1
gBoolShowErr = True
FUN_ErrInfo = "操作错误"
Case -10
FUN_ErrInfo = "设备未打开"
Case -11
FUN_ErrInfo = "设备已经打开"
Case -12
gBoolShowErr = True
FUN_ErrInfo = "读写器未联机"
Case -13
gBoolShowErr = True
FUN_ErrInfo = "错误的调用参数"
Case -14
FUN_ErrInfo = "操作已超时"
Case -15
FUN_ErrInfo = "用户中断"
Case -16
FUN_ErrInfo = "ESC中断"
Case -17
FUN_ErrInfo = "输入缓冲区为空"
Case -100
FUN_ErrInfo = "设备忙"
End Select
End Function