frmlogin.frm文件源代码:
Public OK As Boolean
Private Sub cmdCancel_Click()
OK = False
Me.Hide '隐藏窗体
End Sub
Private Sub cmdOK_Click()
Dim Number As String * 20 '声明长度为20的字符串
Filenum = FreeFile 'FreeFile取得未使用的文件号
Open "c:\rbcic\ktxbps.dat" For Random As #Filenum Len = 20
'"c:\rbcic\ktxbps.dat"为路径,Random为随机输入方式,#Filenum为文件号,Len为记录长度
Get #Filenum, 1, Number 'get为文件读操作,#Filenum文件号。1读取记录号,Number用来存放读取的数据
Close #Filenum '关闭文件 号
'解密
Dim plain_text As String
Decipher txtPassword.Text, Trim(Number), plain_text '调用sub过程Decipher
If txtPassword.Text = plain_text Then
OK = True
Me.Hide
Else
MsgBox "输入密码错误!", vbExclamation, "严重错误":
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
End Sub
Private Function NumericPassword(ByVal password As String) As Long
Dim value As Long
Dim ch As Long
Dim shift1 As Long
Dim shift2 As Long
Dim i As Integer
Dim str_len As Integer
str_len = Len(password) 'Len得知某字符串的长度(字符数)或某变量的大小(位数)。
For i = 1 To str_len
ch = Asc(Mid$(password, i, 1)) 'Asc返回字符串中首字母的字符代码(ASCII)
value = value Xor (ch * 2 ^ shift1) 'Xor函数相同为0不同为1(位运算)
value = value Xor (ch * 2 ^ shift2) '^次方数
Public OK As Boolean
Private Sub cmdCancel_Click()
OK = False
Me.Hide '隐藏窗体
End Sub
Private Sub cmdOK_Click()
Dim Number As String * 20 '声明长度为20的字符串
Filenum = FreeFile 'FreeFile取得未使用的文件号
Open "c:\rbcic\ktxbps.dat" For Random As #Filenum Len = 20
'"c:\rbcic\ktxbps.dat"为路径,Random为随机输入方式,#Filenum为文件号,Len为记录长度
Get #Filenum, 1, Number 'get为文件读操作,#Filenum文件号。1读取记录号,Number用来存放读取的数据
Close #Filenum '关闭文件 号
'解密
Dim plain_text As String
Decipher txtPassword.Text, Trim(Number), plain_text '调用sub过程Decipher
If txtPassword.Text = plain_text Then
OK = True
Me.Hide
Else
MsgBox "输入密码错误!", vbExclamation, "严重错误":
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
End Sub
Private Function NumericPassword(ByVal password As String) As Long
Dim value As Long
Dim ch As Long
Dim shift1 As Long
Dim shift2 As Long
Dim i As Integer
Dim str_len As Integer
str_len = Len(password) 'Len得知某字符串的长度(字符数)或某变量的大小(位数)。
For i = 1 To str_len
ch = Asc(Mid$(password, i, 1)) 'Asc返回字符串中首字母的字符代码(ASCII)
value = value Xor (ch * 2 ^ shift1) 'Xor函数相同为0不同为1(位运算)
value = value Xor (ch * 2 ^ shift2) '^次方数