本文主要是介绍VB6四字节卡号相互转换源码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
读卡器介绍:ID IC ICode 2 HID ICLASS 二代证RFID读卡器USB模拟键盘输出卡号-淘宝网 (taobao.com)
Private Sub Command1_Click()
Dim H2b As Double
Dim L2b As Double
Dim i As Integer
Dim HexStr, wg34 As StringDim lsh
Dim mypiccdata(4) As Bytelsh = Val(Text1)
If lsh > 4294967295# ThenMsgBox "数据大于4字节会溢出!请重新输入", vbCritical + vbOKOnly, "提示"Text1.SetFocusExit Sub
End IfH2b = Int(lsh / (65536))
L2b = lsh - H2b * 65536HexStr = Right("0000" + Hex(H2b), 4) + Right("0000" + Hex(L2b), 4)
Text4 = HexStrFor i = 0 To 3mypiccdata(i) = "&H" + Mid(HexStr, i * 2 + 1, 2)Text2(i) = mypiccdata(i)Text3(i) = Right("00" + Hex(mypiccdata(i)), 2)
Nextdoublecardhao = mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text5 = Format(doublecardhao, "00000000")doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text6 = Format(mypiccdata(1), "000") + Format(doublecardhao, "00000")doublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
wg34 = Format(doublecardhao, "00000")
doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text7 = wg34 + Format(doublecardhao, "00000")End SubPrivate Sub Command2_Click()
Dim i As Integer
Dim HexStr As String
Dim mypiccdata(4) As Byte
Dim doublecardhao As DoubleHexStr = Right("00000000" + Trim(Text4), 8)
Text4 = HexStrFor i = 0 To 3Text3(i) = Mid(HexStr, i * 2 + 1, 2)mypiccdata(i) = "&H" + Mid(HexStr, i * 2 + 1, 2)Text2(i) = mypiccdata(i)
Nextdoublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text1 = Format(doublecardhao, "0000000000")doublecardhao = mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text5 = Format(doublecardhao, "00000000")doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text6 = Format(mypiccdata(1), "000") + Format(doublecardhao, "00000")doublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
wg34 = Format(doublecardhao, "00000")
doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text7 = wg34 + Format(doublecardhao, "00000")End SubPrivate Sub Command3_Click()
Dim i As Integer
Dim HexStr As String
Dim mypiccdata(4) As Byte
Dim doublecardhao As DoubleFor i = 0 To 3If Text2(i) = "" ThenMsgBox "请输入正确的十进制数据!", vbCritical + vbOKOnly, "提示"Text2(i).SetFocusExit SubEnd If
NextHexStr = ""
For i = 0 To 3mypiccdata(i) = Val(Text2(i))Text3(i) = Right("00" + Hex(Val(Text2(i))), 2)HexStr = HexStr + Right("00" + Hex(Val(Text2(i))), 2)
Next
Text4 = HexStrdoublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text1 = Format(doublecardhao, "0000000000")doublecardhao = mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text5 = Format(doublecardhao, "00000000")doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text6 = Format(mypiccdata(1), "000") + Format(doublecardhao, "00000")doublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
wg34 = Format(doublecardhao, "00000")
doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text7 = wg34 + Format(doublecardhao, "00000")
End SubPrivate Sub Command4_Click()
Dim i As Integer
Dim HexStr As String
Dim mypiccdata(4) As Byte
Dim doublecardhao As DoubleFor i = 0 To 3If Text3(i) = "" ThenMsgBox "请输入正确的十六进制数据!", vbCritical + vbOKOnly, "提示"Text3(i).SetFocusExit SubEnd If
NextHexStr = ""
For i = 0 To 3mypiccdata(i) = "&H" + Trim(Text3(i))Text2(i) = mypiccdata(i)HexStr = HexStr + Right("00" + Trim(Text3(i)), 2)
Next
Text4 = HexStrdoublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text1 = Format(doublecardhao, "0000000000")doublecardhao = mypiccdata(1)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text5 = Format(doublecardhao, "00000000")doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text6 = Format(mypiccdata(1), "000") + Format(doublecardhao, "00000")doublecardhao = mypiccdata(0)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(1)
wg34 = Format(doublecardhao, "00000")
doublecardhao = mypiccdata(2)
doublecardhao = doublecardhao * 256
doublecardhao = doublecardhao + mypiccdata(3)
Text7 = wg34 + Format(doublecardhao, "00000")
End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)Select Case KeyAsciiCase 13Command1_ClickCase vbKey0 To vbKey9, vbKeyBackCase ElseKeyAscii = 0End Select
End Sub
Private Sub Text2_KeyPress(Index As Integer, KeyAscii As Integer)Select Case KeyAsciiCase vbKey0 To vbKey9, vbKeyBackCase ElseKeyAscii = 0End Select
End SubPrivate Sub Text2_LostFocus(Index As Integer)
If Text2(Index) > 255 ThenMsgBox "请输入0-255之间的数!", vbCritical + vbOKOnly, "提示"Text2(Index) = 0Text2(Index).SetFocus
End If
End SubPrivate Sub Text3_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case KeyAsciiCase vbKey0 To vbKey9, vbKeyBackCase 97 To 102Case 65 To 70Case ElseKeyAscii = 0End Select
End SubPrivate Sub Text4_KeyPress(KeyAscii As Integer)
Select Case KeyAsciiCase 13Command3_ClickCase vbKey0 To vbKey9, vbKeyBackCase 97 To 102Case 65 To 70Case ElseKeyAscii = 0End Select
End Sub
这篇关于VB6四字节卡号相互转换源码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!