VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1 
   BackColor       =   &H80000016&
   Caption         =   "T55x7 Write (ChinaReader)"
   ClientHeight    =   7920
   ClientLeft      =   60
   ClientTop       =   750
   ClientWidth     =   10560
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000010&
   Icon            =   "FORM1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   7920
   ScaleWidth      =   10560
   Begin ComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   660
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10560
      _ExtentX        =   18627
      _ExtentY        =   1164
      ButtonWidth     =   1032
      ButtonHeight    =   1005
      Appearance      =   1
      ImageList       =   "ImageList1"
      _Version        =   327682
      BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} 
         NumButtons      =   5
         BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "chkkey"
            Object.ToolTipText     =   "核对密码"
            Object.Tag             =   ""
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "rdcard"
            Object.ToolTipText     =   "读卡信息"
            Object.Tag             =   ""
            ImageIndex      =   4
         EndProperty
         BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "writecard"
            Object.ToolTipText     =   "写卡操作"
            Object.Tag             =   ""
            ImageIndex      =   3
            Style           =   1
         EndProperty
         BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "rdcardtype"
            Object.ToolTipText     =   "读卡類型"
            Object.Tag             =   ""
            ImageIndex      =   5
         EndProperty
         BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} 
            Key             =   "unlink"
            Object.ToolTipText     =   "断连接串口"
            Object.Tag             =   ""
            ImageIndex      =   2
         EndProperty
      EndProperty
      BorderStyle     =   1
      Begin ComctlLib.ImageList ImageList1 
         Left            =   3360
         Top             =   960
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   32
         ImageHeight     =   32
         MaskColor       =   12632256
         _Version        =   327682
         BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
            NumListImages   =   5
            BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
               Picture         =   "FORM1.frx":0442
               Key             =   ""
            EndProperty
            BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
               Picture         =   "FORM1.frx":075C
               Key             =   ""
            EndProperty
            BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
               Picture         =   "FORM1.frx":0A76
               Key             =   ""
            EndProperty
            BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
               Picture         =   "FORM1.frx":0D90
               Key             =   ""
            EndProperty
            BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
               Picture         =   "FORM1.frx":10AA
               Key             =   ""
            EndProperty
         EndProperty
      End
   End
   Begin VB.TextBox Text10 
      BackColor       =   &H8000000F&
      Height          =   315
      Left            =   600
      TabIndex        =   33
      Text            =   "Text10"
      Top             =   6000
      Width           =   9615
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H80000004&
      Caption         =   "MODE"
      Height          =   855
      Left            =   600
      TabIndex        =   27
      Top             =   6480
      Width           =   9615
      Begin VB.ComboBox Combo3 
         Height          =   330
         ItemData        =   "FORM1.frx":13C4
         Left            =   4440
         List            =   "FORM1.frx":13E0
         TabIndex        =   36
         Text            =   "Combo3"
         Top             =   360
         Width           =   855
      End
      Begin VB.ComboBox Combo2 
         Height          =   330
         ItemData        =   "FORM1.frx":13FC
         Left            =   2640
         List            =   "FORM1.frx":1406
         TabIndex        =   35
         Text            =   "Combo2"
         Top             =   360
         Width           =   855
      End
      Begin VB.ComboBox Combo1 
         Height          =   330
         ItemData        =   "FORM1.frx":1410
         Left            =   960
         List            =   "FORM1.frx":1420
         TabIndex        =   34
         Text            =   "Combo1"
         Top             =   360
         Width           =   975
      End
      Begin VB.TextBox Text9 
         Height          =   315
         Left            =   6960
         TabIndex        =   32
         Text            =   "Text9"
         Top             =   360
         Width           =   1935
      End
      Begin VB.Label Label12 
         BackColor       =   &H80000004&
         Caption         =   "PassWord:"
         Height          =   255
         Left            =   5760
         TabIndex        =   31
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label11 
         BackColor       =   &H80000004&
         Caption         =   "BLOCK:"
         Height          =   255
         Left            =   3720
         TabIndex        =   30
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label10 
         BackColor       =   &H80000004&
         Caption         =   "LOCK:"
         Height          =   255
         Left            =   2040
         TabIndex        =   29
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label9 
         BackColor       =   &H80000004&
         Caption         =   "OPCODE:"
         Height          =   255
         Left            =   120
         TabIndex        =   28
         Top             =   360
         Width           =   855
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H80000004&
      Caption         =   "T55x7 Function "
      Height          =   4575
      Left            =   6960
      TabIndex        =   18
      Top             =   1200
      Width           =   3255
      Begin VB.CommandButton Command8 
         Caption         =   "T55x7_Read"
         Height          =   255
         Left            =   240
         TabIndex        =   26
         Top             =   3360
         Width           =   2895
      End
      Begin VB.CommandButton Command7 
         Caption         =   "Reset_Command"
         Height          =   255
         Left            =   240
         TabIndex        =   25
         Top             =   2520
         Width           =   2895
      End
      Begin VB.CommandButton Command6 
         Caption         =   "Page_Regular_Read"
         Height          =   255
         Left            =   240
         TabIndex        =   24
         Top             =   2160
         Width           =   2895
      End
      Begin VB.CommandButton Command5 
         Caption         =   "Direct_Access"
         Height          =   255
         Left            =   240
         TabIndex        =   23
         Top             =   1800
         Width           =   2895
      End
      Begin VB.CommandButton Command4 
         Caption         =   "Direct_Access_PWD"
         Height          =   255
         Left            =   240
         TabIndex        =   22
         Top             =   1440
         Width           =   2895
      End
      Begin VB.CommandButton Command3 
         Caption         =   "Wake_Up"
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   1080
         Width           =   2895
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Protected_Write"
         Height          =   255
         Left            =   240
         TabIndex        =   20
         Top             =   720
         Width           =   2895
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H8000000D&
         Caption         =   "Standard_Write"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   360
         Width           =   2895
      End
   End
   Begin VB.TextBox Text8 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   9
      Text            =   "Text8"
      Top             =   5400
      Width           =   3975
   End
   Begin VB.TextBox Text7 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   8
      Text            =   "Text7"
      Top             =   4800
      Width           =   3975
   End
   Begin VB.TextBox Text6 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   7
      Text            =   "Text6"
      Top             =   4200
      Width           =   3975
   End
   Begin VB.TextBox Text5 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   6
      Text            =   "Text5"
      Top             =   3600
      Width           =   3975
   End
   Begin VB.TextBox Text4 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   5
      Text            =   "Text4"
      Top             =   3000
      Width           =   3975
   End
   Begin VB.TextBox Text3 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   4
      Text            =   "Text3"
      Top             =   2400
      Width           =   3975
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   3
      Text            =   "Text2"
      Top             =   1800
      Width           =   3975
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2160
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   1200
      Width           =   3975
   End
   Begin ComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   270
      Left            =   0
      TabIndex        =   1
      Top             =   7650
      Width           =   10560
      _ExtentX        =   18627
      _ExtentY        =   476
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
         NumPanels       =   4
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Object.Width           =   2822
            MinWidth        =   2822
            TextSave        =   ""
            Key             =   "status"
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Object.Width           =   6526
            MinWidth        =   6526
            TextSave        =   ""
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Object.Width           =   6526
            MinWidth        =   6526
            TextSave        =   ""
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            TextSave        =   ""
            Key             =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Timer Timer1 
      Interval        =   200
      Left            =   120
      Top             =   5400
   End
   Begin VB.Label Label8 
      BackColor       =   &H80000004&
      Caption         =   "Label8"
      Height          =   375
      Left            =   720
      TabIndex        =   17
      Top             =   5520
      Width           =   1215
   End
   Begin VB.Label Label7 
      BackColor       =   &H80000004&
      Caption         =   "Label7"
      Height          =   375
      Left            =   720
      TabIndex        =   16
      Top             =   4920
      Width           =   1215
   End
   Begin VB.Label Label6 
      BackColor       =   &H80000004&
      Caption         =   "Label6"
      Height          =   375
      Left            =   720
      TabIndex        =   15
      Top             =   4320
      Width           =   1215
   End
   Begin VB.Label Label5 
      BackColor       =   &H80000004&
      Caption         =   "Label5"
      Height          =   375
      Left            =   720
      TabIndex        =   14
      Top             =   3720
      Width           =   1215
   End
   Begin VB.Label Label4 
      BackColor       =   &H80000004&
      Caption         =   "Label4"
      Height          =   375
      Left            =   720
      TabIndex        =   13
      Top             =   3120
      Width           =   1215
   End
   Begin VB.Label Label3 
      BackColor       =   &H80000004&
      Caption         =   "Label3"
      Height          =   375
      Left            =   720
      TabIndex        =   12
      Top             =   2520
      Width           =   1215
   End
   Begin VB.Label Label2 
      BackColor       =   &H80000004&
      Caption         =   "Label2"
      Height          =   375
      Left            =   720
      TabIndex        =   11
      Top             =   1920
      Width           =   1215
   End
   Begin VB.Label Label1 
      BackColor       =   &H80000004&
      Caption         =   "Label1"
      Height          =   375
      Left            =   720
      TabIndex        =   10
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Menu s_com 
      Caption         =   "Port"
      Begin VB.Menu s_com1 
         Caption         =   "COM 1"
      End
      Begin VB.Menu s_com2 
         Caption         =   "COM 2"
      End
      Begin VB.Menu s_com3 
         Caption         =   "COM 3"
      End
      Begin VB.Menu s_com4 
         Caption         =   "COM 4"
      End
      Begin VB.Menu s_com6 
         Caption         =   "-"
      End
      Begin VB.Menu s_com5 
         Caption         =   "Unlink Port"
      End
   End
   Begin VB.Menu s_card 
      Caption         =   "选择卡型"
      Begin VB.Menu s_card1 
         Caption         =   "MIFARE"
         Begin VB.Menu s_card11 
            Caption         =   "MIFARE 1"
         End
         Begin VB.Menu s_card12 
            Caption         =   "MIFARE LIGHT"
         End
      End
      Begin VB.Menu s_card2 
         Caption         =   "TEMIC"
         Begin VB.Menu s_card21 
            Caption         =   "E5550(1)"
         End
      End
      Begin VB.Menu s_card3 
         Caption         =   "88RF256"
         Begin VB.Menu s_card31 
            Caption         =   "RF256-12"
         End
      End
   End
   Begin VB.Menu c_card 
      Caption         =   "Card"
      Begin VB.Menu c_ck 
         Caption         =   "Write Em4001 Format"
         Shortcut        =   {F4}
      End
      Begin VB.Menu c_card2 
         Caption         =   "-"
      End
      Begin VB.Menu c_rd 
         Caption         =   "Read T55x7"
         Shortcut        =   {F3}
      End
      Begin VB.Menu c_card3 
         Caption         =   "-"
      End
      Begin VB.Menu c_wr 
         Caption         =   "Write Block ""0"""
      End
      Begin VB.Menu c_chk 
         Caption         =   "更改密碼"
      End
      Begin VB.Menu c_card4 
         Caption         =   "-"
      End
      Begin VB.Menu c_stop 
         Caption         =   "停 止 卡"
      End
   End
   Begin VB.Menu about_1 
      Caption         =   "About"
   End
   Begin VB.Menu exit 
      Caption         =   "EXIT"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim inqsta As String
Dim aa As Integer
Dim linkcom, unlinkcom As Integer
Dim writeyn As Integer
Dim linkcomyn As Integer
Dim ctype As String


Private Sub about_1_Click()
frmAbout.Show
End Sub

Private Sub c_chk_Click()
Form2.Show
End Sub

'Dim block2 As String
'Dim block3 As String
'Dim block4 As String
'Dim block5 As String
'Dim block6 As String
'Dim block7 As String
'Dim block8 As String
'Dim block9 As String'
'Dim block10 As String
'Dim block11 As String
'Dim block0 As String
'linkcomyn = 0

Private Sub c_ck_Click()
  'Form2.Show
End Sub

Private Sub c_rd_Click()
' If cardtype = "" Then
'   aa = MsgBox("沒選卡型！", vbOKOnly, "警告")
'   Exit Sub
'   Else
'        Text1.ForeColor = &H80000008
'        Text2.ForeColor = &H80000008
'        Text3.ForeColor = &H80000008
'        Text4.ForeColor = &H80000008
'        Text5.ForeColor = &H80000008
'        Text6.ForeColor = &H80000008
'        Text7.ForeColor = &H80000008
'
'       Dim block7 As String
'        'block0 = ""
'
'        Text1.Text = ""
'        Text2.Text = ""
'        Text3.Text = ""
'        Text4.Text = ""
'        Text5.Text = ""
'        Text6.Text = ""
'        Text7.Text = ""
'
'        block7 = Space(56)
'        ''选择卡型,对应卡型读卡.
'        'cardtype = "E5550"     '只是E5550卡
'        Select Case cardtype
'        Case "MIFARE LIGHT"
'        For i = 1 To 3
'        aa = rd_card(18, 0, 0, 4, block0)
'        Next
'        aa = rd_card(18, 0, 1, 4, block1)
'        aa = rd_card(18, 0, 2, 4, block2)
'        aa = rd_card(18, 0, 3, 4, block3)
'        aa = rd_card(18, 0, 4, 4, block4)
'        aa = rd_card(18, 0, 5, 4, block5)
'        aa = rd_card(18, 0, 6, 4, block6)
'        aa = rd_card(18, 0, 7, 4, block7)
'        aa = rd_card(18, 0, 8, 4, block8)
'        aa = rd_card(18, 0, 9, 4, block9)
'        aa = rd_card(18, 0, 10, 4, block10)
'        aa = rd_card(18, 0, 11, 4, block11)
'        's_com3.Enabled = True
'        Text4.Text = block0
'        Text5.Text = block1
'        Text6.Text = block2
'        Text7.Text = block3
'        Text8.Text = block4
'
'        'Text16.Text = "block12"
'        Case "MIFARE 1"
'
'        Case "RF256-12"
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 0, 4, block7)
'            If aa = 0 Then
'             Text1.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text1.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 1, 4, block7)
'            If aa = 0 Then
'             Text2.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text2.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 2, 4, block7)
'            If aa = 0 Then
'             Text3.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text3.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 3, 4, block7)
'            If aa = 0 Then
'             Text4.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text4.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 4, 4, block7)
'            If aa = 0 Then
'             Text5.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text5.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 5, 4, block7)
'            If aa = 0 Then
'             Text6.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text6.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 6, 4, block7)
'            If aa = 0 Then
'             Text7.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text7.Text = "00000000"
'            End If
'        blcok7 = Space(8)
'        aa = rd_card(18, 0, 7, 4, block7)
'            If aa = 0 Then
'             Text8.Text = UCase(Mid(block7, 1, 8))
'              Else
'             Text8.Text = "00000000"
'            End If
'
'        Case "E5550"
'        block7 = Space(56)
'        aa = rd_card(18, 0, 7, 28, block7)
'        If aa = 0 Then
'        Text1.Text = Mid(block7, 1, 8)
'        Text2.Text = Mid(block7, 9, 8)
'        Text3.Text = Mid(block7, 17, 8)
'        Text4.Text = Mid(block7, 25, 8)
'        Text5.Text = Mid(block7, 33, 8)
'        Text6.Text = Mid(block7, 41, 8)
'        Text7.Text = Mid(block7, 49, 8)
'        Else
'         aa = rd_card(18, 0, 6, 24, block7)
'         If aa = 0 Then
'            Text1.Text = Mid(block7, 1, 8)
'            Text2.Text = Mid(block7, 9, 8)
'            Text3.Text = Mid(block7, 17, 8)
'            Text4.Text = Mid(block7, 25, 8)
'            Text5.Text = Mid(block7, 33, 8)
'            Text6.Text = Mid(block7, 41, 8)
'         Else
'            aa = rd_card(18, 0, 5, 20, block7)
'            If aa = 0 Then
'               Text1.Text = Mid(block7, 1, 8)
'               Text2.Text = Mid(block7, 9, 8)
'               Text3.Text = Mid(block7, 17, 8)
'               Text4.Text = Mid(block7, 25, 8)
'               Text5.Text = Mid(block7, 33, 8)
'            Else
'                aa = rd_card(18, 0, 4, 16, block7)
'                If aa = 0 Then
'                   Text1.Text = Mid(block7, 1, 8)
'                   Text2.Text = Mid(block7, 9, 8)
'                   Text3.Text = Mid(block7, 17, 8)
'                   Text4.Text = Mid(block7, 25, 8)
'                Else
'
'                    aa = rd_card(18, 0, 3, 12, block7)
'                    If aa = 0 Then
'                       Text1.Text = Mid(block7, 1, 8)
'                       Text2.Text = Mid(block7, 9, 8)
'                       Text3.Text = Mid(block7, 17, 8)
'                    Else
'                        aa = rd_card(18, 0, 2, 8, block7)
'                        If aa = 0 Then
'                           Text1.Text = Mid(block7, 1, 8)
'                           Text2.Text = Mid(block7, 9, 8)
'                        Else
'                            aa = rd_card(18, 0, 1, 4, block7)
'                            If aa = 0 Then
'                               Text1.Text = Mid(block7, 1, 8)
'                            Else
'               End If
'             End If
'          End If
'        End If
'       End If
'     End If
'    End If
'        End Select
' End If
End Sub

Private Sub c_stop_Click()
aa = power_off()
If aa = 0 Then
    StatusBar1.Panels(2).Text = "感應區內卡片已停止！"
  Else
    StatusBar1.Panels(2).Text = "停止卡不成功！"
End If

End Sub

Private Sub c_wr_Click()
' Form3.Show
End Sub




Private Sub Command1_Click()
Dim i&, m&, buf1(200) As Byte, buf2(200) As Byte, s1$, b1 As Byte, b2 As Byte, b3 As Byte
Dim aa As Integer, opcode As Byte, lockbit As Byte, block As Byte, status As Long
'b1 = List2.Text
b2 = Combo1.Text
If (b2 <> 10) And (b2 <> 11) Then
   aa = MsgBox("OpCode Error ,Must Be '10' or '11' ！", vbOKOnly, "Alert！")
   Exit Sub
End If
If b2 = 10 Then
opcode = 2
End If
If b2 = 11 Then
opcode = 3
End If


 
b1 = Combo3.Text
'b1 = 3
Select Case b1
  Case 1
    s1 = Trim(Text1.Text)
  Case 2
    s1 = Trim(Text2.Text)
  Case 3
    s1 = Trim(Text3.Text)
  Case 4
    s1 = Trim(Text4.Text)
  Case 5
    s1 = Trim(Text5.Text)
  Case 6
    s1 = Trim(Text6.Text)
  Case 7
    s1 = Trim(Text7.Text)

End Select


'  s1 = Trim(tx_key.Text)
If (Len(s1) <> 8) Then
   ' lb_info.Caption = "密钥长度不对！"
   ' Text(1).SetFocus
   aa = MsgBox("Data Length Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If

block = CByte(b1)
lockbit = CByte(Combo2.Text)
For i = 0 To 3
    buf1(i) = Val("&H" & Mid(s1, i * 2 + 1, 2))
Next i


'i = rf_M1_write(0, b3, buf2(0))
'Public Declare Function Standard_Write Lib "MasterRD.dll" (ByVal opcode As Byte, ByVal lockbit As Byte, _
ByRef buff As Byte, ByVal block As Byte) As Long
'i = Standard_Write(opcode, lockbit, buf1(0), block)
status = Standard_Write(opcode, lockbit, buf1(0), block)

If (status <> 0) Then
     aa = MsgBox("Write Card Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If
status = rf_beep(0, 6)
StatusBar1.Panels(2).Text = "Write Card Succeed ！"


End Sub

Private Sub Command2_Click()
'aa = power_off()
Dim i&, m&, buf1(200) As Byte, buf2(200) As Byte, s1$, b1 As Byte, b2 As Byte, b3 As Byte
Dim aa As Integer, opcode As Byte, lockbit As Byte, block As Byte, status As Long
'b1 = List2.Text
'Public Declare Function Protected_Writer Lib "MasterRD.dll" (ByVal opcode As Byte, _
' ByRef password As Byte, lockbit As Byte, ByRef buff As Byte, ByVal block As Byte) As Long
b2 = Combo1.Text
If (b2 <> 10) And (b2 <> 11) Then
   aa = MsgBox("OpCode Error ,Must Be '10' or '11' ！", vbOKOnly, "Alert！")
   Exit Sub
End If
If b2 = 10 Then
opcode = 2
End If
If b2 = 11 Then
opcode = 3
End If


b1 = Combo3.Text
'b1 = 3
Select Case b1
  Case 1
    s1 = Trim(Text1.Text)
  Case 2
    s1 = Trim(Text2.Text)
  Case 3
    s1 = Trim(Text3.Text)
  Case 4
    s1 = Trim(Text4.Text)
  Case 5
    s1 = Trim(Text5.Text)
  Case 6
    s1 = Trim(Text6.Text)
  Case 7
    s1 = Trim(Text7.Text)

End Select
   
'  s1 = Trim(tx_key.Text)
If (Len(s1) <> 8) Then
   ' lb_info.Caption = "密钥长度不对！"
   ' Text(1).SetFocus
   aa = MsgBox("Data Length Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If

block = CByte(b1)
lockbit = CByte(Combo2.Text)
For i = 0 To 3
    buf1(i) = Val("&H" & Mid(s1, i * 2 + 1, 2))
Next i
' get password
  s1 = Trim(Text9.Text)
If (Len(s1) <> 8) Then
   aa = MsgBox("PassWord Length Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If
For i = 0 To 3
    buf2(i) = Val("&H" & Mid(s1, i * 2 + 1, 2))
Next i


'i = rf_M1_write(0, b3, buf2(0))
'Public Declare Function Standard_Write Lib "MasterRD.dll" (ByVal opcode As Byte, ByVal lockbit As Byte, _
ByRef buff As Byte, ByVal block As Byte) As Long
'i = Standard_Write(opcode, lockbit, buf1(0), block)
status = Protected_Write(opcode, buf2(0), lockbit, buf1(0), block)

If (status <> 0) Then
     aa = MsgBox("Write Card Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If

StatusBar1.Panels(2).Text = "Protected Write Card Succeed ！"
status = rf_beep(0, 6)


End Sub

Private Sub Command3_Click()
 Dim i As Long, password(10) As Byte, s1$

'MSComm1.CommPort = 1
'MSComm1.PortOpen = True
'MSComm1.Output = Chr(2) & "123"
'Text1.Text = MSComm1.Input
'if mscomm1.
'mscomm1.
'MSComm1.PortOpen = True
s1 = Trim(Text9.Text)
If (Len(s1) <> 8) Then
   aa = MsgBox("PassWord Length Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If
For i = 0 To 3
    password(i) = Val("&H" & Mid(s1, i * 2 + 1, 2))
Next i

i = Wake_Up(password(0))

If (i <> 0) Then
     aa = MsgBox("WakeUp Fail ！", vbOKOnly, "Alert！")
     Exit Sub
    ' StatusBar1.Panels(2).Text = "Read Card Fail"
End If
     StatusBar1.Panels(2).Text = "WakeUp Command Succeed ."
status = rf_beep(0, 6)
End Sub

Private Sub Command4_Click()
'aa = wr_card(2, 0, 0, 4, "11111111")
Dim i&, password(10) As Byte, s1$, b1 As Byte, b2 As Byte, b3 As Byte
Dim aa As Integer, opcode As Byte, lockbit As Byte, block As Byte, status As Long

b2 = Combo1.Text
If (b2 <> 10) And (b2 <> 11) Then
   aa = MsgBox("OpCode Error ,Must Be '10' or '11' ！", vbOKOnly, "Alert！")
   Exit Sub
End If
If b2 = 10 Then
  opcode = 2
End If
If b2 = 11 Then
  opcode = 3
End If
'get password
s1 = Trim(Text9.Text)
If (Len(s1) <> 8) Then
   aa = MsgBox("PassWord Length Error ！", vbOKOnly, "Alert！")
    Exit Sub
End If
For i = 0 To 3
    password(i) = Val("&H" & Mid(s1, i * 2 + 1, 2))
Next i

block = CByte(Combo3.Text)



status = Direct_Access_PWD(opcode, password(0), block)

If (status <> 0) Then
  aa = MsgBox("Direct Access PWD Command Fail ！", vbOKOnly, "Alert！")
   'StatusBar1.Panels(2).Text = status
  
  Exit Sub
End If
StatusBar1.Panels(2).Text = "Direct Access PWD Succeed ."

status = rf_beep(0, 6)
End Sub

Private Sub Command5_Click()
'aa = wr_card(2, 0, 0, 4, "11111111")
Dim i&, s1$, b1 As Byte, b2 As Byte, b3 As Byte
Dim aa As Integer, opcode As Byte, lockbit As Byte, block As Byte, status As Long

b2 = Combo1.Text
If (b2 <> 10) And (b2 <> 11) Then
   aa = MsgBox("OpCode Error ,Must Be '10' or '11' ！", vbOKOnly, "Alert！")
   Exit Sub
End If
If b2 = 10 Then
  opcode = 2
End If
If b2 = 11 Then
  opcode = 3
End If
'get password

block = CByte(Combo3.Text)



status = Direct_Access(opcode, block)

If (status <> 0) Then
  aa = MsgBox("Direct Access Command Fail ！", vbOKOnly, "Alert！")
   'StatusBar1.Panels(2).Text = status
  
  Exit Sub
End If
StatusBar1.Panels(2).Text = "Direct Access Succeed ."
status = rf_beep(0, 6)
End Sub

Private Sub Command6_Click()
'aa = wr_card(2, 0, 2, 4, "11111111")
Dim i&, m&, buf1(200) As Byte, buf2(200) As Byte, s1$, b1 As Byte, b2 As Byte, b3 As Byte
Dim aa As Integer, opcode As Byte, lockbit As Byte, block As Byte, status As Long

b2 = Combo1.Text
If (b2 <> 10) And (b2 <> 11) Then
   aa = MsgBox("OpCode Error ,Must Be '10' or '11' ！", vbOKOnly, "Alert！")
   Exit Sub
End If
If b2 = 10 Then
  opcode = 2
End If
If b2 = 11 Then
  opcode = 3
End If

status = Page_Regular_Read(opcode)
If (status <> 0) Then
  aa = MsgBox("Page Regular Read Command Fail ！", vbOKOnly, "Alert！")
   StatusBar1.Panels(2).Text = status
  
  Exit Sub
End If
StatusBar1.Panels(2).Text = "Page Regular Read Command Succeed ."
status = rf_beep(0, 6)
End Sub

Private Sub Command7_Click()
 Dim i As Long, buff(50) As Byte, s1$, DataLength As Byte, j&, port&, baud&

'MSComm1.CommPort = 1
'MSComm1.PortOpen = True
'MSComm1.Output = Chr(2) & "123"
'Text1.Text = MSComm1.Input
'if mscomm1.
'mscomm1.
'MSComm1.PortOpen = True
i = Reset_Command()
If (i <> 0) Then
     aa = MsgBox("Reset Command Fail ！", vbOKOnly, "Alert！")
     Exit Sub
    ' StatusBar1.Panels(2).Text = "Read Card Fail"
End If
     StatusBar1.Panels(2).Text = "Reset Command Succeed ."
status = rf_beep(0, 6)

End Sub

Private Sub Command8_Click()
 Dim i As Long, buff(50) As Byte, s1$, DataLength As Byte, j&, port&, baud&
 Text10.Text = ""
 i = T55x7_Read(DataLength, buff(0))

If (i <> 0) Then
     aa = MsgBox("Read Card Fail ！", vbOKOnly, "Alert！")
     StatusBar1.Panels(2).Text = "Read Card Fail"
     Exit Sub
End If
s1 = ""
If (DataLength > 0) Then
   For i = 0 To DataLength - 1
    s1 = s1 & Right("00" & Hex(buff(i)), 2)
   Next i
End If

Text10.Text = s1
status = rf_beep(0, 6)

End Sub

Private Sub Command9_Click()
 Dim i As Long, buff(50) As Byte, s1$, DataLength As Byte, j&, port&, baud&
 Text10.Text = ""
 i = Read_Em4001(buff(0))

If (i <> 0) Then
     aa = MsgBox("Read Card Fail ！", vbOKOnly, "Alert！")
     StatusBar1.Panels(2).Text = "Read Card Fail"
     Exit Sub
End If
s1 = ""
   For i = 0 To 4
   s1 = s1 & Right("00" & Hex(buff(i)), 2)
   Next i

Text10.Text = s1
 status = rf_beep(0, 6)
End Sub

Private Sub exit_Click()

'aa = unlink_com(linkcom)

Unload Me
End Sub



Private Sub Form_Load()
Form1.s_card1.Enabled = False
'Form1.s_card1.Visible = False
Form1.s_card.Visible = False
'Form1.s_card3.Visible = False

'Form1.c_ck.Enabled = False
Form1.c_wr.Enabled = False
Form1.c_rd.Enabled = False
Form1.c_chk.Enabled = False
Form1.c_stop.Enabled = False
   Form1.Width = Screen.Width * 0.75 ' 设置窗体的宽度。
   Form1.Height = Screen.Height * 0.75
   Form1.Left = (Screen.Width - Width) / 2    ' 在水平方向上居中显示。
   Form1.Top = (Screen.Height - Height) / 2

ctype = "Card Type："

'Label1.Caption = "第一塊："
'Label2.Caption = "第二塊："
'Label3.Caption = "第三塊："
'Label4.Caption = "第四塊："
'Label5.Caption = "第五塊："
'Label6.Caption = "第六塊："
'Label7.Caption = "第七塊："
Label1.Caption = "BLOCK 1 :"
Label2.Caption = "BLOCK 2 :"
Label3.Caption = "BLOCK 3 :"
Label4.Caption = "BLOCK 4 :"
Label5.Caption = "BLOCK 5 :"
Label6.Caption = "BLOCK 6 :"
Label7.Caption = "BLOCK 7 :"

Label8.Visible = False
linkcomyn = 0   '读写器没连接。
linkcom = -1
cardtype = ""   '没有选择任何卡型。
status = Space(8) '没有任何选取。
's_com2.Enabled = False
'Text1.Text = ""
''Text3.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""

Combo1.ListIndex = 2
Combo2.ListIndex = 0
 
 Combo3.ListIndex = 0
Text8.Visible = False
'Text1.MaxLength = 16
'Text2.MaxLength = 16
'Text3.MaxLength = 16
'Text4.MaxLength = 16
'Text5.MaxLength = 16
'Text6.MaxLength = 16
'Text7.MaxLength = 16
Text1.MaxLength = 8
Text2.MaxLength = 8
Text3.MaxLength = 8
Text4.MaxLength = 8
Text5.MaxLength = 8
Text6.MaxLength = 8
Text7.MaxLength = 8
Text9.MaxLength = 8

Text1.Locked = False      '将各个文本设定成不可编辑。
Text2.Locked = False
Text3.Locked = False
Text4.Locked = False
Text5.Locked = False
Text6.Locked = False
Text7.Locked = False
Text8.Locked = False
'Form1.c_rd.Enabled = True  '设置默认的卡型为"MIFARE LIGHT"
'Form1.c_wr.Enabled = False
status = Space(8)
'Frame1.ZOrder 0
'cardtype = "E5550"
cardtype = ""
Toolbar1.Buttons(1).Enabled = False
Toolbar1.Buttons(3).Visible = False
Toolbar1.Buttons(2).Enabled = False
s_card21_Click
End Sub

Private Sub Form_Unload(Cancel As Integer)
unlinkcom = unlink_com(linkcom)
End Sub



Private Sub MSComm1_OnComm()

End Sub

Private Sub s_card11_Click()
Frame2.ZOrder 0
cardtype = "MIFARE 1"
Form1.c_rd.Enabled = False
Form1.c_wr.Enabled = False
End Sub

Private Sub s_card12_Click()
Frame1.ZOrder 0
cardtype = "MIFARE LIGHT"
Form1.c_rd.Enabled = False
Form1.c_wr.Enabled = False
End Sub

Private Sub s_card21_Click()
cardtype = "E5557"
Form1.c_rd.Enabled = True
Form1.c_wr.Enabled = True
'Form1.c_ck.Enabled = True
Form1.c_chk.Visible = False
Form1.c_stop.Visible = False
StatusBar1.Panels(2) = ctype + "Temic E5557"
'Form1.c_ck.Enabled = False
'Label1.Caption = "第一塊："
'Label2.Caption = "第二塊："
'Label3.Caption = "第三塊："
'Label4.Caption = "第四塊："
'Label5.Caption = "第五塊："
'Label6.Caption = "第六塊："
'Label7.Caption = "第七塊："
Label1.Caption = "BLOCK 1 :"
Label2.Caption = "BLOCK 2 :"
Label3.Caption = "BLOCK 3 :"
Label4.Caption = "BLOCK 4 :"
Label5.Caption = "BLOCK 5 :"
Label6.Caption = "BLOCK 6 :"
Label7.Caption = "BLOCK 7 :"
Label8.Visible = False
Text8.Visible = False
Text1.MaxLength = 8
Text2.MaxLength = 8
Text3.MaxLength = 8
Text4.MaxLength = 8
Text5.MaxLength = 8
Text6.MaxLength = 8
Text7.MaxLength = 8
Text8.MaxLength = 8
Toolbar1.Buttons(1).Enabled = False
Toolbar1.Buttons(2).Enabled = True
End Sub

Private Sub s_card31_Click()
cardtype = "RF256-12"
Form1.c_rd.Enabled = True
Form1.c_wr.Enabled = True
'Form1.c_ck.Enabled = True
Form1.c_chk.Enabled = True
Form1.c_stop.Enabled = True
Form1.c_chk.Visible = True
Form1.c_stop.Visible = True
StatusBar1.Panels(2) = ctype + "88RF256-12"
Label1.Caption = "第零塊："
Label2.Caption = "第一塊："
Label3.Caption = "第二塊："
Label4.Caption = "第三塊："
Label5.Caption = "第四塊："
Label6.Caption = "第五塊："
Label7.Caption = "第六塊："
Label8.Caption = "序列號："
Label8.Visible = True
Text8.Visible = True
Text8.Locked = True
'
Text1.MaxLength = 8
Text2.MaxLength = 8
Text3.MaxLength = 8
Text4.MaxLength = 8
Text5.MaxLength = 8
Text6.MaxLength = 8
Text7.MaxLength = 8
Text8.MaxLength = 8
'
Toolbar1.Buttons(1).Enabled = True
Toolbar1.Buttons(2).Enabled = True

End Sub

Private Sub s_com1_Click()
Dim i&, baud&, port&
Dim tmp As String
Select Case linkcomyn
Case 0                       '判断是否已连串口，如没连，连；如已连，断后连
tmp = "19200"
baud = CLng(tmp)
port = 1
   i = rf_init_com(port, baud)
   If (i <> 0) Then
     aa = MsgBox("Link Com Port 1 Fail ！", vbOKOnly, "Warning！")
     Exit Sub
   End If

 ' linkcom = link_com(3)      '如失败，警告。
  '  If linkcom >= 0 Then
     StatusBar1.Panels(1).Text = "Port 1 Selected "
     linkcomyn = 1
 '     Else
 '    StatusBar1.Panels(1).Text = ""
  '   aa = MsgBox("选择串口四错误！", vbOKOnly, "警告！")
  '   linkcomyn = 2
 '   End If
Case 1
  aa = MsgBox("A Port Had Been Selected ,Continue ？", vbOKCancel, "Note")
    If aa = 1 Then
    
      'aa = unlink_com(linkcom)
     aa = rf_ClosePort()
     i = rf_init_com(1, 19200)
      If (i <> 0) Then
         aa = MsgBox("Link Com Port 1 Fial ！", vbOKOnly, "Alert ！")
         Exit Sub
      End If

     StatusBar1.Panels(1).Text = "Port 1 Selected "
     linkcomyn = 1
    
    
    End If
Case 2
  StatusBar1.Panels(1).Text = ""
  aa = MsgBox("错误，请确认读写器是否正确连接。", vbOKOnly, "警告！")
End Select
End Sub

Private Sub s_com2_Click()
Dim i&, baud&, port&
Dim tmp As String
Select Case linkcomyn
Case 0                       '判断是否已连串口，如没连，连；如已连，断后连
tmp = "19200"
baud = CLng(tmp)
port = 2
   i = rf_init_com(port, baud)
   If (i <> 0) Then
     aa = MsgBox("Link Com Port 2 Fail ！", vbOKOnly, "Warning！")
     Exit Sub
   End If

 ' linkcom = link_com(3)      '如失败，警告。
  '  If linkcom >= 0 Then
  
     StatusBar1.Panels(1).Text = "Port 2 Selected "
     linkcomyn = 1
 '     Else
 '    StatusBar1.Panels(1).Text = ""
  '   aa = MsgBox("选择串口四错误！", vbOKOnly, "警告！")
  '   linkcomyn = 2
 '   End If
Case 1
  aa = MsgBox("A Port Had Been Selected ,Continue ？", vbOKCancel, "Note")
    If aa = 1 Then
    
      'aa = unlink_com(linkcom)
     aa = rf_ClosePort()
     i = rf_init_com(2, 19200)
      If (i <> 0) Then
         aa = MsgBox("Link Com Port 2 Fial ！", vbOKOnly, "Alert ！")
         Exit Sub
      End If

     StatusBar1.Panels(1).Text = "Port 2 Selected "
     MsgBox ("打开串口成功！")
     linkcomyn = 1
    End If
Case 2
  StatusBar1.Panels(1).Text = ""
  aa = MsgBox("错误，请确认读写器是否正确连接。", vbOKOnly, "警告！")
End Select
End Sub

Private Sub s_com3_Click()
Dim i&, baud&, port&
Dim tmp As String
Select Case linkcomyn
Case 0                       '判断是否已连串口，如没连，连；如已连，断后连
tmp = "19200"
baud = CLng(tmp)
port = 3
   i = rf_init_com(port, baud)
   If (i <> 0) Then
     aa = MsgBox("Link Com Port 3 Fail ！", vbOKOnly, "Warning！")
     Exit Sub
   End If

 ' linkcom = link_com(3)      '如失败，警告。
  '  If linkcom >= 0 Then
     StatusBar1.Panels(1).Text = "Port 3 Selected "
     linkcomyn = 1
 '     Else
 '    StatusBar1.Panels(1).Text = ""
  '   aa = MsgBox("选择串口四错误！", vbOKOnly, "警告！")
  '   linkcomyn = 2
 '   End If
Case 1
  aa = MsgBox("A Port Had Been Selected ,Continue ？", vbOKCancel, "Note")
    If aa = 1 Then
    
      'aa = unlink_com(linkcom)
     aa = rf_ClosePort()
     i = rf_init_com(3, 19200)
      If (i <> 0) Then
         aa = MsgBox("Link Com Port 3 Fial ！", vbOKOnly, "Alert ！")
         Exit Sub
      End If

     StatusBar1.Panels(1).Text = "Port 3 Selected "
     linkcomyn = 1
    
    
    End If
Case 2
  StatusBar1.Panels(1).Text = ""
  aa = MsgBox("错误，请确认读写器是否正确连接。", vbOKOnly, "警告！")
End Select

End Sub

Private Sub s_com4_Click()
Dim i&, baud&, port&
Dim tmp As String
Select Case linkcomyn
Case 0                       '判断是否已连串口，如没连，连；如已连，断后连
tmp = "19200"
baud = CLng(tmp)
port = 4
   i = rf_init_com(port, baud)
   If (i <> 0) Then
     aa = MsgBox("Link Com Port 4 Fail ！", vbOKOnly, "Warning！")
     Exit Sub
   End If

 ' linkcom = link_com(3)      '如失败，警告。
  '  If linkcom >= 0 Then
     StatusBar1.Panels(1).Text = "Port 4 Selected "
     linkcomyn = 1
 '     Else
 '    StatusBar1.Panels(1).Text = ""
  '   aa = MsgBox("选择串口四错误！", vbOKOnly, "警告！")
  '   linkcomyn = 2
 '   End If
Case 1
  aa = MsgBox("A Port Had Been Selected ,Continue ？", vbOKCancel, "Note")
    If aa = 1 Then
    
      'aa = unlink_com(linkcom)
     aa = rf_ClosePort()
     i = rf_init_com(4, 19200)
      If (i <> 0) Then
         aa = MsgBox("Link Com Port 4 Fial ！", vbOKOnly, "Alert ！")
         Exit Sub
      End If

     StatusBar1.Panels(1).Text = "Port 4 Selected "
     linkcomyn = 1
    
    
    End If
Case 2
  StatusBar1.Panels(1).Text = ""
  aa = MsgBox("错误，请确认读写器是否正确连接。", vbOKOnly, "警告！")
End Select

End Sub

Private Sub s_com5_Click()
'aa = unlink_com(linkcom)
Dim status As Long
  status = rf_ClosePort()
If status = 0 Then
StatusBar1.Panels(1).Text = "Unlink Port Succeed"
linkcomyn = 0
Else
StatusBar1.Panels(1).Text = "Unlink Port Fail"
End If

End Sub




Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  
Select Case cardtype
   Case "E5550"
   Text1.Locked = False
   Text1.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text1.Text) <> 8 And Len(Text1.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 1, 4, readcard)
      Text1.Text = readcard
      Text1.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text1.Text)
        Case 8
            aa = wr_card(18, 0, 1, 4, Text1.Text)
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 1, 4, readcard)
             If UCase(readcard) = UCase(Text1.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text1.ForeColor = &H80000008
                    Text1.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 1, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text1.Text = readcard
                        Text1.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 1, 8, Text1.Text)
            readcard = Space(8)
            aa = rd_card(18, 0, 1, 4, readcard)
             If UCase(readcard) = UCase(Mid(Text1.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text1.ForeColor = &H80000008
                    Text1.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 1, 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text1.Text = readcard
                        Text1.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If

 Case "RF256-12"
  Text1.Locked = False
  Text1.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text1.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 0, 4, readcard)
      Text1.Text = UCase(readcard)
      Text1.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 0, 4, Text1.Text)
            readcard = Space(8)
            
            
            aa = rd_card(18, 0, 0, 4, readcard)
             If UCase(readcard) = UCase(Text1.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text1.ForeColor = &H80000008
                    Text1.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 0, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text1.Text = readcard
                        Text1.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select

End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select
End Sub


Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case cardtype
   Case "E5550"
   Text2.Locked = False
   Text2.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text2.Text) <> 8 And Len(Text2.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(16)
      readcard = Mid(rd_card(18, 0, 2, 8, readcard), 9, 8)
      Text2.Text = readcard
      Text2.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text2.Text)
        Case 8
           For i = 0 To 10
            aa = wr_card(18, 0, 2, 4, Text2.Text)
           Next
            readcard = Space(16)
            aa = rd_card(18, 0, 2, 8, readcard)
             If UCase(Mid(readcard, 9, 8)) = UCase(Text2.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text2.ForeColor = &H80000008
                    Text2.Text = Mid(readcard, 9, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(16)
                    aa = rd_card(18, 0, 2, 8, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text2.Text = Mid(readcard, 9, 8)
                        Text2.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 2, 8, Text2.Text)
            readcard = Space(16)
            aa = rd_card(18, 0, 2, 8, readcard)
             If UCase(Mid(readcard, 9, 8)) = UCase(Mid(Text2.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text2.ForeColor = &H80000008
                    Text2.Text = Mid(readcard, 9, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(16)
                    aa = rd_card(18, 0, 2, 8, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text2.Text = Mid(readcard, 9, 8)
                        Text2.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text2.Locked = False
  Text2.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text2.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 1, 4, readcard)
      Text2.Text = UCase(readcard)
      Text2.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 1, 4, Text2.Text)
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 1, 4, readcard)
             
             If UCase(readcard) = UCase(Text2.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text2.ForeColor = &H80000008
                    Text2.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 1, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text2.Text = readcard
                        Text2.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case cardtype
   Case "E5550"
   Text3.Locked = False
   Text3.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text3.Text) <> 8 And Len(Text3.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(3 * 8)
      readcard = Mid(rd_card(18, 0, 3, 3 * 4, readcard), 9 + 8, 8)
      Text3.Text = readcard
      Text3.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text3.Text)
        Case 8
            aa = wr_card(18, 0, 3, 4, Text3.Text)
            readcard = Space(3 * 8)
            aa = rd_card(18, 0, 3, 3 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8, 8)) = UCase(Text3.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text3.ForeColor = &H80000008
                    Text3.Text = Mid(readcard, 9 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(3 * 8)
                    aa = rd_card(18, 0, 3, 3 * 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text3.Text = Mid(readcard, 9 + 8, 8)
                        Text3.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 3, 8, Text3.Text)
            readcard = Space(3 * 8)
            aa = rd_card(18, 0, 3, 3 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8, 8)) = UCase(Mid(Text3.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text3.ForeColor = &H80000008
                    Text3.Text = Mid(readcard, 9 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(3 * 8)
                    aa = rd_card(18, 0, 3, 3 * 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text3.Text = Mid(readcard, 9 + 8, 8)
                        Text3.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text3.Locked = False
  Text3.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text3.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 2, 4, readcard)
      Text3.Text = UCase(readcard)
      Text3.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 2, 4, Text3.Text)
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 2, 4, readcard)
             If UCase(readcard) = UCase(Text3.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text3.ForeColor = &H80000008
                    Text3.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 2, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text3.Text = readcard
                        Text3.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
   Select Case cardtype
   Case "E5550"
   Text4.Locked = False
   Text4.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text4.Text) <> 8 And Len(Text4.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(4 * 8)
      readcard = Mid(rd_card(18, 0, 4, 4 * 4, readcard), 9 + 8 + 8, 8)
      Text4.Text = readcard
      Text4.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text4.Text)
        Case 8
            aa = wr_card(18, 0, 4, 4, Text4.Text)
            readcard = Space(4 * 8)
            aa = rd_card(18, 0, 4, 4 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8, 8)) = UCase(Text4.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text4.ForeColor = &H80000008
                    Text4.Text = Mid(readcard, 9 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(4 * 8)
                    aa = rd_card(18, 0, 4, 4 * 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text4.Text = Mid(readcard, 9 + 8 + 8, 8)
                        Text4.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 4, 8, Text4.Text)
            readcard = Space(4 * 8)
            aa = rd_card(18, 0, 4, 4 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8, 8)) = UCase(Mid(Text4.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text4.ForeColor = &H80000008
                    Text4.Text = Mid(readcard, 9 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(4 * 8)
                    aa = rd_card(18, 0, 4, 4 * 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text4.Text = Mid(readcard, 9 + 8 + 8, 8)
                        Text4.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text4.Locked = False
  Text4.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text4.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
        aa = rd_card(18, 0, 3, 4, readcard)
      Text4.Text = UCase(readcard)
      Text4.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 3, 4, Text4.Text)
            readcard = Space(8)
            For i = 0 To 20000
              i = i + 1
            Next
            aa = rd_card(18, 0, 3, 4, readcard)
             If UCase(readcard) = UCase(Text4.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text4.ForeColor = &H80000008
                    Text4.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 3, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text4.Text = readcard
                        Text4.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select
End Sub


Private Sub Text4_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text5_keydown(KeyCode As Integer, Shift As Integer)
Select Case cardtype
Case "E5550"
   Text5.Locked = False
   Text5.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text5.Text) <> 8 And Len(Text5.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(5 * 8)
      readcard = Mid(rd_card(18, 0, 5, 5 * 4, readcard), 9 + 8 + 8 + 8, 8)
      Text5.Text = readcard
      Text5.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text5.Text)
        Case 8
            aa = wr_card(18, 0, 5, 4, Text5.Text)
            readcard = Space(5 * 8)
            aa = rd_card(18, 0, 5, 5 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8, 8)) = UCase(Text5.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text5.ForeColor = &H80000008
                    Text5.Text = Mid(readcard, 9 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(5 * 8)
                    aa = rd_card(18, 0, 5, 5 * 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text5.Text = Mid(readcard, 9 + 8 + 8 + 8, 8)
                        Text5.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 5, 8, Text5.Text)
            readcard = Space(5 * 8)
            aa = rd_card(18, 0, 5, 5 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8, 8)) = UCase(Mid(Text5.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text5.ForeColor = &H80000008
                    Text5.Text = Mid(readcard, 9 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(5 * 8)
                    aa = rd_card(18, 0, 5, 5 * 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text5.Text = Mid(readcard, 9 + 8 + 8 + 8, 8)
                        Text5.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text5.Locked = False
  Text5.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text5.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 4, 4, readcard)
      Text5.Text = UCase(readcard)
      Text5.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 4, 4, Text5.Text)
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 4, 4, readcard)
             If UCase(readcard) = UCase(Text5.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text5.ForeColor = &H80000008
                    Text5.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 4, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text5.Text = readcard
                        Text5.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select

End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case cardtype
 Case "E5550"
   Text6.Locked = False
   Text6.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text6.Text) <> 8 And Len(Text6.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(6 * 8)
      readcard = Mid(rd_card(18, 0, 6, 6 * 4, readcard), 9 + 8 + 8 + 8 + 8, 8)
      Text6.Text = readcard
      Text6.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text6.Text)
        Case 8
            aa = wr_card(18, 0, 6, 4, Text6.Text)
            readcard = Space(6 * 8)
            aa = rd_card(18, 0, 6, 6 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)) = UCase(Text6.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text6.ForeColor = &H80000008
                    Text6.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(6 * 8)
                    aa = rd_card(18, 0, 6, 6 * 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text6.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)
                        Text6.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 6, 8, Text6.Text)
            readcard = Space(6 * 8)
            aa = rd_card(18, 0, 6, 6 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)) = UCase(Mid(Text6.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text6.ForeColor = &H80000008
                    Text6.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(6 * 8)
                    aa = rd_card(18, 0, 6, 6 * 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text6.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8, 8)
                        Text6.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text6.Locked = False
  Text6.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text6.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 5, 4, readcard)
      Text6.Text = UCase(readcard)
      Text6.ForeColor = &H80000008
     Exit Sub
    Else
            aa = wr_card(18, 0, 5, 4, Text6.Text)
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 5, 4, readcard)
             If UCase(readcard) = UCase(Text6.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text6.ForeColor = &H80000008
                    Text6.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 5, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text6.Text = readcard
                        Text6.ForeColor = &H80000008
                    End If
             End If
   End If
  End If

End Select
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case cardtype
  Case "E5550"
  Text7.Locked = False
   Text7.ForeColor = &H80000001
   If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text7.Text) <> 8 And Len(Text7.Text) <> 16 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(7 * 8)
      readcard = Mid(rd_card(18, 0, 6, 7 * 4, readcard), 9 + 8 + 8 + 8 + 8 + 8, 8)
      Text7.Text = readcard
      Text7.ForeColor = &H80000008
     Exit Sub
    Else
        Select Case Len(Text7.Text)
        Case 8
            aa = wr_card(18, 0, 7, 4, Text7.Text)
            readcard = Space(7 * 8)
            aa = rd_card(18, 0, 7, 7 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)) = UCase(Text7.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text7.ForeColor = &H80000008
                    Text7.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(7 * 8)
                    aa = rd_card(18, 0, 7, 7 * 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text7.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)
                        Text7.ForeColor = &H80000008
                    End If
             End If
        Case 16
            aa = wr_card(18, 0, 7, 8, Text7.Text)
            readcard = Space(7 * 8)
            aa = rd_card(18, 0, 7, 7 * 4, readcard)
             If UCase(Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)) = UCase(Mid(Text7.Text, 9, 8)) Then
                aa = 0
                Else: aa = 1
             End If
             
             If aa = 0 Then
                    'readcard = Space(8)
                    'aa = rd_card(18, 0, 1, 4, readcard)
                    Text7.ForeColor = &H80000008
                    Text7.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(7 * 8)
                    aa = rd_card(18, 0, 7, 7 * 4, readcard)
                    If aa = 0 Then  '如讀不正确，不變顯示。
                        Text7.Text = Mid(readcard, 9 + 8 + 8 + 8 + 8 + 8, 8)
                        Text7.ForeColor = &H80000008
                    End If
             End If
        End Select
   End If
End If
Case "RF256-12"
  Text7.Locked = False
  Text7.ForeColor = &H80000001
  If KeyCode = vbKeyReturn Then  '如有回車，寫卡。
   If Len(Text7.Text) <> 8 Then
      aa = MsgBox("寫入字長有誤！", vbOKOnly, "錯誤")
      readcard = Space(8)
      aa = rd_card(18, 0, 6, 4, readcard)
      Text7.Text = UCase(readcard)
      Text7.ForeColor = &H80000008
     Exit Sub
    Else
'        For i = 1 To 10 Step 1
            aa = wr_card(18, 0, 6, 4, Text7.Text)
        'Next
            readcard = Space(8)
            For i = 0 To 10000
              i = i + 1
            Next
            aa = rd_card(18, 0, 6, 4, readcard)
             If UCase(readcard) = UCase(Text7.Text) Then
                aa = 0
                Else: aa = 1
             End If
             '
             If aa = 0 Then
                   ' readcard = Space(8)
                   ' aa = rd_card(18, 0, 1, 4, readcard)
                    Text7.ForeColor = &H80000008
                    Text7.Text = readcard
                 Else
                    aa = MsgBox("寫卡末成功！", vbOKOnly, "錯誤")
                    readcard = Space(8)
                    aa = rd_card(18, 0, 6, 4, readcard)
                    If aa = 0 Then   '如讀不正确，不變顯示。
                        Text7.Text = readcard
                        Text7.ForeColor = &H80000008
                    End If
             End If
   End If
  End If
End Select
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("输入值应为“0-F”", vbOKOnly, "警告！")
    KeyAscii = 0
  End Select

End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)
 Dim i As Integer
  Select Case KeyAscii
    Case 48 To 57
    Case 8
    Case 13
    Case 105
    Case 97 To 102
    Case 65 To 70
    Case Else:
    aa = MsgBox("Key Vaule Must Be“0-F”", vbOKOnly, "Alert！")
    KeyAscii = 0
  End Select
End Sub

Private Sub Timer1_Timer()
StatusBar1.Panels(4).Text = Time
If StatusBar1.Panels(4).Text <> Time Then StatusBar1.Panels(4).Text = Time
'If DelayFlag = True Then DelayTime = DelayTime + 1


End Sub

Private Sub Timer2_Timer()
c_rd_Click
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
'If cardtype = "" Then
' aa = MsgBox("沒有選擇卡型！", vbOKOnly, "警告！")
' ElseIf linkcom < 0 Then
If linkcom < 0 Then
 aa = MsgBox("沒有正确選擇串口！", vbOKOnly, "警告！")
 Else
 
    Select Case Button.Key    '判断按键值。
     Case "chkkey"
        If cardtype = "" Then
          aa = MsgBox("沒有選擇卡型！", vbOKOnly, "警告！")
          Exit Sub
        End If
     c_ck_Click
     Case "rdcard"
        If cardtype = "" Then
          aa = MsgBox("沒有選擇卡型！", vbOKOnly, "警告！")
          Exit Sub
        End If
     c_rd_Click
     Case "writecard"     'writeyn=0 不能写卡,=1能写卡
    '  If Toolbar1.Buttons(3).Value = tbrPressed Then
    '   Text4.Locked = False
    '   Text5.Locked = False
    '   Text6.Locked = False
    '   Text7.Locked = False
    '   Text8.Locked = False
      
    '  Else
    '   Text4.Locked = True
    '   Text5.Locked = True
    '   Text6.Locked = True
    '   Text7.Locked = True
    '   Text8.Locked = True
    '   Text9.Locked = True
    '   Text10.Locked = True
    '   Text11.Locked = True
    '   Text12.Locked = True
    ''   Text13.Locked = True
     '  Text14.Locked = True
     ''  Text15.Locked = True
     'End If
     '  wrireyn = 1
      'Print 3
     Case "rdcardtype"
     StatusBar1.Panels(2) = ""
     cardtype = Space(8)
     aa = inq_status(cardtype)
     If Mid(cardtype, 1, 2) = "08" Then
        Text2.Text = ""
        Text1.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
     cardtype = "E5550"
     StatusBar1.Panels(2) = ctype + "Temic E5550"
     
s_card21_Click
     
     ElseIf Mid(cardtype, 1, 2) = "12" Then
        Text2.Text = ""
        Text1.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
     cardtype = "RF256-12"
     StatusBar1.Panels(2) = ctype + "AT-RF256-12"
s_card31_Click
     
     Else
       aa = MsgBox("末知錯誤，沒卡或串口連接錯！", vbOKOnly, "出錯！")
       cardtype = ""
        Text2.Text = ""
        Text1.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
     End If
   '  Print 4
     Case "unlink"
    End Select
End If
  wrcard = 1
End Sub

Private Sub writey()
Select Case cardtype
 Case "MIFARE 1"
   
 Case "MIFARE LIGHT"
   Text7.Locked = False
 Case "E5550"
 Case "RF256-12"

End Select
End Sub

