Hi,

I have a program here, for encrypting text using caesar cipher....except, I don't know how to get it to input the encrypted text back into my input text box! Here's what i have so far:

Any help appreciated, I'm sure it's only a minor thing but when I was getting help this morning I forgot to ask before my tutorial ended!

Private Sub cmdEn_Click()
Dim key As Integer, plain As String, cipher As String
key = Val(txtKey.Text)
plain = txtInput.Text
If key >= 0 And key <= 25 Then
    cipher = Encrypt(plain, key)
    txtInput.Text = cipher
Else
    txtInput.Text = "The key must be between 0 and 25, thanks."
End If
End Sub
Private Sub cmdExit_Click()
End
End Sub

Private Function Encrypt(plaintext As String, code As Integer)
Dim i As Integer
Dim char As String
Dim temp As String
Dim temp_asc As Integer
For i = 1 To Len(plaintext)
char = Mid(plaintext, i, 1)
If asc_char >= 97 And asc_char <= 122 Then
temp_asc = Asc(char) + code
    If temp_asc > 122 Then
    temp_asc = 96 + (temp_asc - 122)
    End If
temp = temp & Chr(temp_asc)
Else
temp = temp + char
End If
Next i
Encrypt = temp
End Function
textinput.text=Encrypt(textinput.text As String, code As Integer)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.