新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Function f_EDcode(strMy As String, intKey As Integer)
Dim X As Single, i As Long
Dim CharNum As Integer, RandomInteger As Integer
Dim CharSingle As String * 1
On Local Error GoTo f_EDcodeError
f_EDcode = ""
If Len(strMy) = 0 Then
f_EDcode = "1"
Exit Function
End If
X = Rnd(-intKey)
For i = 1 To Len(strMy)
CharSingle = Mid(strMy, i, 1)
CharNum = Asc(CharSingle)
RandomInteger = Int(256 * Rnd) And &H7F
CharNum = CharNum Xor RandomInteger
CharSingle = Chr(CharNum)
f_EDcode = f_EDcode + CharSingle
Next i
Exit Function
f_EDcodeError:
f_EDcode = "0"
End Function
Private Sub Command1_Click()
Dim strMy As String
Dim intKey As Integer
Dim strA As String
strMy = "码农库MaNongKu.com就是那么好用!"
intKey = 9998
strA = f_EDcode(strMy, intKey)
MsgBox strA
strA = f_EDcode(strA, intKey)
MsgBox strA
End Sub