📄 速度密码.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "速度密码测试"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "退出"
Height = 285
Left = 3465
TabIndex = 3
Top = 1575
Width = 960
End
Begin VB.CommandButton Command2
Caption = "新密码"
Height = 285
Left = 3465
TabIndex = 2
Top = 1012
Width = 960
End
Begin VB.CommandButton Command1
Caption = "密码测试"
Height = 285
Left = 3465
TabIndex = 1
Top = 450
Width = 960
End
Begin VB.Frame Frame1
Height = 2940
Left = 180
TabIndex = 0
Top = 135
Width = 3075
Begin VB.TextBox Text1
Height = 270
Left = 1035
TabIndex = 6
Top = 2115
Width = 1725
End
Begin VB.Label Label5
Caption = "密 码:"
Height = 195
Left = 270
TabIndex = 9
Top = 2160
Width = 735
End
Begin VB.Label Label4
Caption = "相似度:"
Height = 195
Left = 270
TabIndex = 8
Top = 1575
Width = 735
End
Begin VB.Label Label3
Caption = "信 息:"
Height = 240
Left = 270
TabIndex = 7
Top = 405
Width = 735
End
Begin VB.Label Label2
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 240
Left = 1035
TabIndex = 5
Top = 1575
Width = 1725
End
Begin VB.Label Label1
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 690
Left = 1035
TabIndex = 4
Top = 405
Width = 1725
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MMok As Boolean
Private Type SpeedKey
Chrl As Byte
Timer1 As Single
End Type
Dim Akey(99) As SpeedKey, Bkey(99) As SpeedKey
Dim Busy As Boolean
Dim NewStr As String, TestStr As String
Private Sub Command1_Click()
Dim TestLike As Single
If Not MMok Then Exit Sub
If Busy Then Exit Sub
Label1.Caption = "正在测试密码..."
Call InputAKey(TestStr, TestLike)
Label1.Caption = "测试密码完毕"
If TestLike = 0 Or NewStr <> TestStr Then
MsgBox "密码不正确"
Else
Label2.Caption = Format(TestLike, "#0.##")
If TestLike > 0.5 Then
Label1.Caption = "速度不像"
Else
Label1.Caption = "速度比较像"
End If
End If
Command1.SetFocus
End Sub
Private Sub Command2_Click()
Dim i As Long
If Busy Then Exit Sub
Label1.Caption = "正在新建密码..."
Call InputAKey(NewStr, 0)
Label1.Caption = "新建密码完毕"
If Len(NewStr) < 2 Then MsgBox "密码最少要两个字符!": Exit Sub
For i = 0 To 99
Bkey(i) = Akey(i)
Next i
Label1.Caption = "复制数组OK"
MMok = True
Command1.Enabled = True
Command1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
MMok = False
Fir_key = True
If Not MMok Then Command1.Enabled = False
End Sub
Private Sub InputAKey(Str1 As String, Likeitl As Single)
Dim i As Long, Tmp As String, Chayi As Single
Dim CRpos As Long
Dim Acha As Single, Bcha As Single
Text1.Text = ""
Text1.SetFocus
Busy = True
Do
DoEvents
Loop Until Busy = False
i = 0
Do
If Akey(i).Chrl = 13 Then
CRpos = i
Exit Do
End If
Tmp = Tmp & Chr(Akey(i).Chrl)
i = i + 1
Loop
Str1 = Tmp
Chayi = 0
For i = 0 To CRpos - 1
If Akey(i).Chrl <> Bkey(i).Chrl Then
Likeitl = 0
Exit Sub
End If
Acha = Akey(i + 1).Timer1 - Akey(i).Timer1
Bcha = Bkey(i + 1).Timer1 - Bkey(i).Timer1
Chayi = Chayi + Abs(Acha - Bcha)
Next i
Likeitl = Chayi
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Static ii As Long
If Busy Then
Akey(ii).Chrl = KeyAscii
Akey(ii).Timer1 = Timer
ii = ii + 1
Text1.Text = "*" & Text1.Text
If KeyAscii = 13 Then
Busy = False
Text1.Text = String(Len(Text1.Text) - 1, "*")
ii = 0
End If
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -