In a module, add the following -

Option Explicit

'Function to Decrypt the encrypted Data.
Public Function Decrypt(EncText As String, WatchWord As String) As String

'All the Dim things Follows
Dim intKey As Integer
Dim intX As Integer
Dim strChar As String
Dim DecText As String

'The Few Lines that work for us.The Following three
'Lines Create the key to Decrypt the Data.
For intX = 1 To Len(WatchWord)
    intKey = intKey + Asc(Mid(WatchWord, intX)) / 20
Next

'Here is our Engine Room that Decrypts the Data by using the key.
For intX = 1 To Len(EncText)
    strChar = Mid(EncText, intX, 1)
    DecText = DecText & Chr(Asc(strChar) Xor intKey)
Next

'Return the Data.
Decrypt = DecText

'Form1.Text3.Text = Decrypt
End Function


'Function to Encrypt the Plain Text.
Public Function Encrypt(PlainText As String, WatchWord As String) As String

'Other Dim Things
Dim intKey As Integer
Dim intX As Integer
Dim strChar As String
Dim EncText As String

'all Mighty visual Basic lines give us the Key
For intX = 1 To Len(WatchWord)
    intKey = intKey + Asc(Mid(WatchWord, intX)) / 20
Next

'the brother of decrypt function.but it earns its
'living by encrypting the data
For intX = 1 To Len(PlainText)
    strChar = Mid(PlainText, intX, 1)
    EncText = EncText & Chr(Asc(strChar) Xor intKey)
Next

'the ever so generous functios should return something.
Encrypt = EncText

'Form1.Text2.Text = Encrypt
End Function

Call it in your form -

Decrypt (Text1.Text, Text2.Text)
This article has been dead for over six months. Start a new discussion instead.