Simple Encryption

Simple Encryption

Make four text boxes, and two controls. Name the text boxes txtCTC, txtCipher, txtCTDC, and txtDCC. Name the command buttons cmdCipher, and cmdDecipher. Input this code. When you enter a single letter in txtCTC and press cmdCipher, it comes out as a ciphered letter. When you put the ciphered letter in txtCTDC, it comes out as the original letter. This only works with one letter at a time.

Dim Num1 As String
Dim Num2 As String


Private Sub cmdCipher_Click()
Num1 = Asc(txtCTC.Text) 'Converts the letter to a ANSI number
Num1 = Num1 + 3 'Adds three to the ANSI number
Num2 = Chr$(Num1)
'Converts the ANSI number back to a letter
txtCipher.Text = txtCipher.Text + Num2 'Adds the ciphered letter to the end of whatever was previously in the textbox
End Sub

Private Sub cmdDecipher_Click()
Num1 = Asc(txtCTDC.Text) 'Converts the ciphered letter to a ANSI number
Num1 = Num1 - 3 'Subtracts three from the ANSI number
Num2 = Chr$(Num1) 'Converts the ANSI number back to a letter
txtDCC.Text = txtDCC.Text + Num2 'Adds the deciphered letter to the end of whatever was previously in the textbox
End Sub

'Credit goes to Daniel Thompson, A.K.A. HLF926

You might also like...

Comments

 DT

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski