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
Comments