📄 frmmain.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 3 'Fixed Dialog
Caption = "SLE4442"
ClientHeight = 4740
ClientLeft = 45
ClientTop = 330
ClientWidth = 9810
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4740
ScaleWidth = 9810
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton btnCancel
Caption = "Cancel"
Height = 555
Left = 8160
TabIndex = 15
Top = 3960
Width = 1275
End
Begin VB.Frame Frame1
Caption = "Operator"
Height = 3615
Left = 5100
TabIndex = 4
Top = 180
Width = 4455
Begin VB.CommandButton btnReadEC
Caption = "ReadECount"
Height = 555
Left = 2940
TabIndex = 20
Top = 1800
Width = 1275
End
Begin VB.CommandButton btnReadP
Caption = "ReadLockBit"
Height = 555
Left = 240
TabIndex = 19
Top = 2940
Width = 1275
End
Begin VB.TextBox txtLockBit
Height = 270
Left = 1140
Locked = -1 'True
MaxLength = 8
TabIndex = 17
Text = "FFFFFFFF"
Top = 2520
Width = 1095
End
Begin VB.CommandButton btnLock
Caption = "WriteLockBit"
Height = 555
Left = 2940
TabIndex = 16
Top = 660
Width = 1275
End
Begin VB.CommandButton btnChangePwd
Caption = "ChangePwd"
Height = 555
Left = 1560
TabIndex = 14
Top = 1800
Width = 1275
End
Begin VB.TextBox txtPSC
Height = 270
Left = 1140
MaxLength = 6
TabIndex = 12
Text = "FFFFFF"
Top = 1380
Width = 1095
End
Begin VB.CommandButton btnVerify
Caption = "Verify"
Height = 555
Left = 180
TabIndex = 11
Top = 1800
Width = 1275
End
Begin VB.CommandButton btnRead
Caption = "Read"
Height = 555
Left = 180
TabIndex = 10
Top = 660
Width = 1275
End
Begin VB.CommandButton btnWrite
Caption = "Write"
Height = 555
Left = 1560
TabIndex = 9
Top = 660
Width = 1275
End
Begin VB.TextBox txtAddr
Height = 270
Left = 1140
TabIndex = 6
Text = "0"
Top = 300
Width = 435
End
Begin VB.TextBox txtLen
Height = 270
Left = 3180
TabIndex = 5
Text = "256"
Top = 300
Width = 675
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "LockBit"
Height = 180
Left = 240
TabIndex = 18
Top = 2580
Width = 630
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Password"
Height = 180
Left = 240
TabIndex = 13
Top = 1440
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Addr"
Height = 180
Left = 240
TabIndex = 8
Top = 360
Width = 360
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Length"
Height = 180
Left = 2460
TabIndex = 7
Top = 360
Width = 540
End
End
Begin SLE4442.HexText txtDataBuf
Height = 4035
Left = 300
TabIndex = 3
Top = 540
Width = 4695
_ExtentX = 8281
_ExtentY = 7117
BufferSize = 256
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Mutative = -1 'True
End
Begin VB.CommandButton btnDisConnect
Caption = "DisConnect"
Height = 555
Left = 6780
TabIndex = 2
Top = 3960
Width = 1275
End
Begin VB.CommandButton btnConnect
Caption = "Connect"
Height = 555
Left = 5340
TabIndex = 0
Top = 3960
Width = 1275
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Data Buffer"
Height = 180
Left = 360
TabIndex = 1
Top = 240
Width = 990
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub btnChangePwd_Click()
Dim psc(3) As Byte
SCHelp_HexStringToBytes txtPSC.Text, psc(0), 3
If 0 = SC4442_ChangePwd(hPort, psc(0), psc(1), psc(2)) Then
ReportError
Else
MsgBox "Change Password is OK!"
End If
End Sub
Private Sub btnConnect_Click()
Dim ATR(4) As Byte
If 0 = SC_Connect(hPort, "SLE4442", "", ATR(0)) Then
ReportError
Else
Dim strHex As String
strHex = Space(8)
SCHelp_BytesToHexString ATR(0), 4, strHex
MsgBox strHex
End If
End Sub
Private Sub btnCloseReader_Click()
SC_CloseReader hPort
End Sub
Private Sub btnCancel_Click()
Unload Me
End Sub
Private Sub btnLock_Click()
Dim stAddr As Long
Dim count As Long
stAddr = CLng(txtAddr.Text)
count = CLng(txtLen.Text)
GetBufferData txtDataBuf.Text
If stAddr + count > 32 Then
MsgBox "Only the 0~31 bytes can be locked!"
Exit Sub
End If
LockCard stAddr, count
End Sub
Private Sub btnRead_Click()
Dim stAddr As Long
Dim count As Long
stAddr = CLng(txtAddr.Text)
count = CLng(txtLen.Text)
If stAddr + count > 256 Then
MsgBox "The SLE4442 has only 256 bytes!"
Exit Sub
End If
If ReadCard(stAddr, count) Then
txtDataBuf.Text = GetBufferString
End If
End Sub
Private Sub btnReadEC_Click()
Dim EC As Byte
EC = SC4442_ECount(hPort)
If EC < 0 Then
ReportError
Else
MsgBox "Error count is " & EC
End If
End Sub
Private Sub btnReadP_Click()
Dim pbuf(4) As Byte
If 0 = SC4442_ReadLockBit(hPort, pbuf(0)) Then
ReportError
Else
Dim strHex As String
strHex = Space(8)
SCHelp_BytesToHexString pbuf(0), 4, strHex
txtLockBit.Text = strHex
MsgBox "Read OK!"
End If
End Sub
Private Sub btnWrite_Click()
Dim stAddr As Long
Dim count As Long
stAddr = CLng(txtAddr.Text)
count = CLng(txtLen.Text)
GetBufferData txtDataBuf.Text
If stAddr + count > 256 Then
MsgBox "The SLE4442 has only 256 bytes!"
Exit Sub
End If
WriteCard stAddr, count
End Sub
Private Sub btnVerify_Click()
Dim psc(3) As Byte
SCHelp_HexStringToBytes txtPSC.Text, psc(0), 3
If 0 = SC4442_Verify(hPort, psc(0), psc(1), psc(2)) Then
ReportError
Else
MsgBox "Verify is OK!"
End If
End Sub
Private Sub btnDisConnect_Click()
If 0 = SC_DisConnect(hPort, 0) Then
ReportError
End If
End Sub
Private Sub Form_Load()
OpenReader
End Sub
Private Sub Form_Unload(Cancel As Integer)
SC_CloseReader hPort
End Sub
Private Sub txtLockBit_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
KeyCode = 0
End If
End Sub
Private Sub txtLockBit_KeyPress(KeyAscii As Integer)
With txtLockBit
If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
Exit Sub
End If
If KeyAscii = vbKeyBack Then
KeyAscii = 0
If .SelStart <> 0 Then
.SelStart = .SelStart - 1
.SelLength = 1
.SelText = "F"
.SelStart = .SelStart - 1
End If
ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
'大小写转换
If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
KeyAscii = KeyAscii + Asc("A") - Asc("a")
End If
If .SelStart < .MaxLength Then
.SelLength = 1
.SelText = Chr$(KeyAscii)
End If
End If
KeyAscii = 0
.SelLength = 0
End With
End Sub
Private Sub txtPSC_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
KeyCode = 0
End If
End Sub
Private Sub txtPSC_KeyPress(KeyAscii As Integer)
With txtPSC
If KeyAscii = vbKeyUp Or KeyAscii = vbKeyDown Or KeyAscii = vbKeyRight Or KeyAscii = vbKeyLeft Or KeyAscii = vbKeyEnd Or KeyAscii = vbKeyHome Or KeyAscii = vbKeyPageDown Or KeyAscii = vbKeyPageUp Then
Exit Sub
End If
If KeyAscii = vbKeyBack Then
KeyAscii = 0
If .SelStart <> 0 Then
.SelStart = .SelStart - 1
.SelLength = 1
.SelText = "F"
.SelStart = .SelStart - 1
End If
ElseIf (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) _
Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("F")) _
Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("f")) Then
'大小写转换
If KeyAscii >= Asc("a") And KeyAscii <= Asc("f") Then
KeyAscii = KeyAscii + Asc("A") - Asc("a")
End If
If .SelStart < .MaxLength Then
.SelLength = 1
.SelText = Chr$(KeyAscii)
End If
End If
KeyAscii = 0
.SelLength = 0
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -