⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 磁条读写机
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmMain 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "SLE4428"
   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          =   2655
      Left            =   5100
      TabIndex        =   4
      Top             =   180
      Width           =   4455
      Begin VB.ComboBox cmbAddrPage 
         Height          =   300
         ItemData        =   "frmMain.frx":0000
         Left            =   960
         List            =   "frmMain.frx":001C
         Style           =   2  'Dropdown List
         TabIndex        =   20
         Top             =   240
         Width           =   1395
      End
      Begin VB.CommandButton btnReadEC 
         Caption         =   "Error Count"
         Height          =   555
         Left            =   2940
         TabIndex        =   17
         Top             =   1980
         Width           =   1275
      End
      Begin VB.CommandButton btnLock 
         Caption         =   "WriteLock"
         Height          =   555
         Left            =   2940
         TabIndex        =   16
         Top             =   960
         Width           =   1275
      End
      Begin VB.CommandButton btnChangePwd 
         Caption         =   "ChangePwd"
         Height          =   555
         Left            =   1560
         TabIndex        =   14
         Top             =   1980
         Width           =   1275
      End
      Begin VB.TextBox txtPSC 
         Height          =   270
         Left            =   1140
         MaxLength       =   4
         TabIndex        =   12
         Text            =   "FFFF"
         Top             =   1620
         Width           =   1095
      End
      Begin VB.CommandButton btnVerify 
         Caption         =   "Verify"
         Height          =   555
         Left            =   180
         TabIndex        =   11
         Top             =   1980
         Width           =   1275
      End
      Begin VB.CommandButton btnRead 
         Caption         =   "Read"
         Height          =   555
         Left            =   180
         TabIndex        =   10
         Top             =   960
         Width           =   1275
      End
      Begin VB.CommandButton btnWrite 
         Caption         =   "Write"
         Height          =   555
         Left            =   1560
         TabIndex        =   9
         Top             =   960
         Width           =   1275
      End
      Begin VB.TextBox txtAddr 
         Height          =   270
         Left            =   2520
         TabIndex        =   6
         Text            =   "0"
         Top             =   240
         Width           =   435
      End
      Begin VB.TextBox txtLen 
         Height          =   270
         Left            =   960
         TabIndex        =   5
         Text            =   "128"
         Top             =   600
         Width           =   675
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Addr"
         Height          =   180
         Left            =   240
         TabIndex        =   21
         Top             =   300
         Width           =   360
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Password"
         Height          =   180
         Left            =   240
         TabIndex        =   13
         Top             =   1680
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "+"
         Height          =   180
         Left            =   2400
         TabIndex        =   8
         Top             =   300
         Width           =   90
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Length"
         Height          =   180
         Left            =   240
         TabIndex        =   7
         Top             =   660
         Width           =   540
      End
   End
   Begin SLE4428.HexText txtDataBuf 
      Height          =   2055
      Left            =   180
      TabIndex        =   3
      Top             =   300
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   3625
      BufferSize      =   128
      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 SLE4428.HexText txtLockBuf 
      Height          =   2055
      Left            =   180
      TabIndex        =   18
      Top             =   2580
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   3625
      BufferSize      =   128
      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.Label Label5 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Lock Buffer"
      Height          =   180
      Left            =   240
      TabIndex        =   19
      Top             =   2400
      Width           =   990
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Data Buffer"
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   120
      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(2) As Byte
SCHelp_HexStringToBytes txtPSC.Text, psc(0), 2

If 0 = SC4428_ChangePwd(hPort, psc(0), psc(1)) 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, "SLE4428", "", 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 > 128 Then
    MsgBox "Too much data!"
    Exit Sub
End If
LockCard cmbAddrPage.ListIndex, stAddr, count


End Sub

Private Sub btnRead_Click()
If cmbAddrPage.ListIndex < 0 Then Exit Sub

If ReadCard(cmbAddrPage.ListIndex) Then
    txtDataBuf.Text = GetDataBufferString
    txtLockBuf.Text = GetLockBufferString
End If
End Sub

Private Sub btnReadEC_Click()
Dim EC As Byte
EC = SC4428_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 = SC4428_ReadEx(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 > 128 Then
    MsgBox "Too much data!"
    Exit Sub
End If
WriteCard cmbAddrPage.ListIndex, stAddr, count
End Sub

Private Sub btnVerify_Click()
Dim psc(2) As Byte
SCHelp_HexStringToBytes txtPSC.Text, psc(0), 2

If 0 = SC4428_Verify(hPort, psc(0), psc(1)) 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()
cmbAddrPage.ListIndex = 0
OpenReader
End Sub

Private Sub Form_Unload(Cancel As Integer)
SC_CloseReader hPort
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 + -