form2password.frm

来自「一套收费计算机系统」· FRM 代码 · 共 332 行

FRM
332
字号
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form Form2password 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "密码管理"
   ClientHeight    =   2760
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3330
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   2760
   ScaleWidth      =   3330
   Begin VB.TextBox Text3 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   1320
      PasswordChar    =   "*"
      TabIndex        =   7
      Top             =   2280
      Width           =   1935
   End
   Begin VB.TextBox Text2 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   1320
      PasswordChar    =   "*"
      TabIndex        =   5
      Top             =   1440
      Width           =   1935
   End
   Begin VB.TextBox Text1 
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   1320
      PasswordChar    =   "#"
      TabIndex        =   3
      Top             =   600
      Width           =   1935
   End
   Begin MSDataListLib.DataList DataList1 
      Bindings        =   "Form2password.frx":0000
      Height          =   1950
      Left            =   0
      TabIndex        =   1
      Top             =   600
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   3440
      _Version        =   393216
      ListField       =   "操作员"
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   240
      Top             =   1440
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   2
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "FILE NAME=C:\My Documents\花寨子早.UDL"
      OLEDBString     =   ""
      OLEDBFile       =   "C:\My Documents\花寨子早.UDL"
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "操作员库"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label Label4 
      Caption         =   "请再次输入以确认:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1320
      TabIndex        =   6
      Top             =   1920
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "请输入新密码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1320
      TabIndex        =   4
      Top             =   1080
      Width           =   1815
   End
   Begin VB.Label Label2 
      Caption         =   "请输入旧密码:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1320
      TabIndex        =   2
      Top             =   240
      Width           =   1815
   End
   Begin VB.Label Label1 
      Caption         =   "操作员:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   855
   End
End
Attribute VB_Name = "Form2password"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim entrydate As Date
Dim newpw As String
Private Sub DataList1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
'Adodc1.Refresh
Adodc1.Recordset.Find "操作员='" & DataList1.Text & "'", , adSearchForward, 1
End Sub

Private Sub Form_Load()
entrydate = Now()
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call history(staff, entrydate, Me.Caption, Now())
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
'旧密码的输入
  If (KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 97 And KeyAscii <= 122) Or KeyAscii = 13 Or KeyAscii = 8 Then
    If Len(Text1.Text) < 5 Then '当输入小于5个字符时
      If KeyAscii = 13 Then
        If Text1.Text = "" Then
          MsgBox "密码不得为空", vbOKOnly, "警示"
          Text1.SetFocus
          Exit Sub
        Else
          
            If Text1.Text = Adodc1.Recordset.Fields(2).Value Then   '密码相符
               Text2.SetFocus
            Else
               MsgBox "密码不符,请重新输入", vbOKOnly, "警示"
               Text1.SetFocus
            End If
          
        End If
      End If
    End If
  
    If Len(Text1.Text) = 5 Then '当输入等于5个字符时
      If KeyAscii = 13 Then '回车键
            If Text1.Text = Adodc1.Recordset.Fields(2).Value Then   '密码相符
               Text2.SetFocus
            Else
               MsgBox "密码不符,请重新输入", vbOKOnly, "警示"
               Text1.SetFocus
            End If
      Else
        If KeyAscii <> 8 Then '回撤键
          KeyAscii = 0
        End If
      End If
    End If
    
    If Len(Text1.Text) > 5 Then '当输入大于5个字时
    KeyAscii = 0 '取消输入
    End If
  
Else
    KeyAscii = 0
End If
End Sub


Private Sub Text2_KeyPress(KeyAscii As Integer)
'第一次新密码的输入
  If (KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 97 And KeyAscii <= 122) Or KeyAscii = 13 Or KeyAscii = 8 Then
    If Len(Text2.Text) < 5 Then '当输入小于5个字符时
      If KeyAscii = 13 Then
        If Text2.Text = "" Then
          MsgBox "密码不得为空", vbOKOnly, "警示"
          Text2.SetFocus
          Exit Sub
        Else
          newpw = Text2.Text '记住新密码
          Text3.SetFocus
        End If
      End If
    End If
  
    If Len(Text2.Text) = 5 Then '当输入等于5个字符时
      If KeyAscii = 13 Then '回车键
          newpw = Text2.Text '记住新密码
          Text3.SetFocus
      Else
        If KeyAscii <> 8 Then '回撤键
          KeyAscii = 0
        End If
      End If
    End If
    
    If Len(Text2.Text) > 5 Then '当输入大于5个字时
    KeyAscii = 0 '取消输入
    End If
  
Else
    KeyAscii = 0
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
'第二次新密码的输入
  If (KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 97 And KeyAscii <= 122) Or KeyAscii = 13 Or KeyAscii = 8 Then
    If Len(Text3.Text) < 5 Then '当输入小于5个字符时
      If KeyAscii = 13 Then
        If Text3.Text = "" Then
          MsgBox "密码不得为空", vbOKOnly, "警示"
          Text3.SetFocus
          Exit Sub
        Else
          
            If Text3.Text = newpw Then '密码相符
               Adodc1.Recordset.Fields(2).Value = newpw
               Adodc1.Recordset.Update

               Unload Form2password
               Exit Sub
            Else
               MsgBox "密码不符,请重新输入", vbOKOnly, "警示"
               Text3.SetFocus
            End If
          
        End If
      End If
    End If
  
    If Len(Text3.Text) = 5 Then '当输入等于5个字符时
      If KeyAscii = 13 Then '回车键
        If Text3.Text = newpw Then '密码相符
               Adodc1.Recordset.Fields(2).Value = newpw
               Adodc1.Recordset.Update

               Unload Form2password
               Exit Sub
            Else
               MsgBox "密码不符,请重新输入", vbOKOnly, "警示"
               Text3.SetFocus
            End If
      Else
        If KeyAscii <> 8 Then '回撤键
          KeyAscii = 0
        End If
      End If
    End If
    
    If Len(Text3.Text) > 5 Then '当输入大于5个字时
    KeyAscii = 0 '取消输入
    End If
  
Else
    KeyAscii = 0
End If
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?