📄 frmchgpwd.frm
字号:
' ---------------------------------------------------------------------------
' Initialize local variables
' ---------------------------------------------------------------------------
strInText = ""
intLength = Len(m_strPassword)
Set cMD5 = New clsMD5
' ---------------------------------------------------------------------------
' Concatenate the Password / Passphrase entered with the salt value from the
' database and hash the results.
' ---------------------------------------------------------------------------
strInText = strInText & g_strSalt
strHashed = cMD5.MD5_Hash_Data_String(strInText)
Set cMD5 = Nothing
' ---------------------------------------------------------------------------
' compare just the hashed results with the ruslts stored in the database
' ---------------------------------------------------------------------------
If StrComp(strInText, g_strHash, vbTextCompare) = 0 Then
' if a valid password was entered in the password
' textbox and it matched what was on file
' display an error message
MsgBox "We have a password match.", _
vbOKOnly + vbInformation, "Success"
Good_Old_Password = True
Else
' display an error message
MsgBox "Password does not match what is on file.", _
vbOKOnly + vbInformation, "Invalid Data"
Good_Old_Password = False
End If
Normal_Exit:
' ---------------------------------------------------------------------------
' clear variables holding the digital signatures for security reasons.
' Leave nothing in memory.
' ---------------------------------------------------------------------------
strInText = String(intLength, 0)
strInText = ""
End Function
Private Sub Form_Initialize()
' ---------------------------------------------------------------------------
' Centered on the screen
' ---------------------------------------------------------------------------
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
End Sub
Private Sub Form_Load()
' ---------------------------------------------------------------------------
' Make sure we do not show this form when first loading the application
' ---------------------------------------------------------------------------
With frmPWord
.txtPassword(0).Text = ""
.txtPassword(1).Text = ""
.lblMyLabel = "Freeware by Kenneth Ives kenaso@home.com"
.lblTitle = "XYZ Corporation" & vbCrLf & "Password Entry"
.Hide
End With
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' ---------------------------------------------------------------------------
' Empty variables
' ---------------------------------------------------------------------------
Clear_Variables
' ---------------------------------------------------------------------------
' Based on the the unload code the system passes,
' we determine what to do
'
' Unloadmode codes
' 0 - Close from the control-menu box
' or Upper left "X"
' 1 - Unload method from code elsewhere
' in the application
' 2 - Windows Session is ending
' 3 - Task Manager is clostrIng the app
' 4 - MDI Parent is clostrIng
' ---------------------------------------------------------------------------
Select Case UnloadMode
Case 0: cmdChoice_Click 1 ' Return to the main menu
Case 1: Exit Sub
Case 2: StopApplication
Case 3: StopApplication
Case 4: StopApplication
End Select
End Sub
Private Sub txtPassword_GotFocus(Index As Integer)
' ---------------------------------------------------------------------------
' Highlight all the text in the box
' ---------------------------------------------------------------------------
With txtPassword(Index)
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Private Sub txtPassword_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
' ---------------------------------------------------------------------------
' Define local variables
' ---------------------------------------------------------------------------
Dim CtrlDown As Integer
Dim PressedKey As Integer
' ---------------------------------------------------------------------------
' Initialize variables
' ---------------------------------------------------------------------------
CtrlDown = (Shift And vbCtrlMask) > 0 ' Define control key
PressedKey = Asc(UCase(Chr(KeyCode))) ' Convert to uppercase
' ---------------------------------------------------------------------------
' Check to see if it is okay to make changes
' ---------------------------------------------------------------------------
If CtrlDown And PressedKey = vbKeyX Then
Edit_Cut ' Ctrl + X was pressed
ElseIf CtrlDown And PressedKey = vbKeyA Then
With txtPassword(Index) ' Ctrl + A was pressed
.SelStart = 0
.SelLength = Len(.Text)
End With
ElseIf CtrlDown And PressedKey = vbKeyC Then
Edit_Copy ' Ctrl + C was pressed
ElseIf CtrlDown And PressedKey = vbKeyV Then
Edit_Paste ' Ctrl + V was pressed
ElseIf PressedKey = vbKeyDelete Then
Edit_Delete ' Delete key was pressed
End If
End Sub
Private Sub txtPassword_KeyPress(Index As Integer, KeyAscii As Integer)
' ---------------------------------------------------------------------------
' If ENTER is pressed then nullify keystroke and execute the OK button
' ---------------------------------------------------------------------------
If KeyAscii = 13 Then
KeyAscii = 0
cmdChoice(0).SetFocus
SendKeys "{ENTER}"
Exit Sub
End If
' ---------------------------------------------------------------------------
' If TAB is pressed then nullify keystroke and TAB to the next tabstop
' ---------------------------------------------------------------------------
If KeyAscii = 9 Then
KeyAscii = 0
SendKeys "{TAB}"
End If
' ---------------------------------------------------------------------------
' Accept on valid characters
' ---------------------------------------------------------------------------
Select Case KeyAscii
' backspace and other printable
' keyboard characters
Case 8, 32 To 126:
Exit Sub ' Good input
' Bad input
Case Else:
KeyAscii = 0 ' Nullify keystroke
End Select
End Sub
Private Sub txtPassword_LostFocus(Index As Integer)
' ---------------------------------------------------------------------------
' Remove leading and trailing blank spaces
' ---------------------------------------------------------------------------
txtPassword(Index) = Trim(txtPassword(Index))
' ---------------------------------------------------------------------------
' Initial test of the input data
' ---------------------------------------------------------------------------
Select Case Index
' User ID
Case 0:
If Len(txtPassword(0)) > 0 Then
txtPassword(0) = StrConv(txtPassword(0), vbUpperCase)
g_strUserID = txtPassword(0)
Else
g_strUserID = ""
End If
' change has occured in the userID text box
g_strHash = ""
g_strSalt = ""
txtPassword(1) = ""
m_strPassword = ""
' Password
Case Else:
' if something is in the password box
' then save to another variable and
' fill the text box with asteriks
If Len(txtPassword(1)) > 0 Then
m_strPassword = txtPassword(1)
txtPassword(1) = String(30, "*")
Else
' else empty the text box and the
' variable
txtPassword(1) = ""
m_strPassword = ""
End If
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -