Here's something to get you started
Code:
Option Explicit
Dim strCode As String
Private Sub cmdCode_Click()
Dim strToCode As String
Dim strCoded As String
Dim intI As Integer
Dim intChr As Integer
Dim intPos As Integer
strToCode = UCase(Text1.Text)
For intI = 1 To Len(strToCode)
'
' Pick up the next character in the data to encode
' Convert to ASCII
' If it's a space then don't encode it
' Use the ASCII value to index into the Code String
' and pick up up that character as the encoded letter
' Repeat for all data to be encoded
'
intChr = Asc(Mid$(strToCode, intI, 1))
If intChr <> 32 Then
intPos = intChr - Asc("A")
strCoded = strCoded & Mid$(strCode, intPos + 1, 1)
Else
strCoded = strCoded & " "
End If
Next intI
Text2.Text = strCoded
End Sub
Private Sub cmdDecode_Click()
Dim strCoded As String
Dim strDecode As String
Dim strChr As String
Dim intI As Integer
Dim intPos As Integer
strCoded = Text2.Text
For intI = 1 To Len(strCoded)
'
' Pick up the next encoded character
' Find its position within the Code String
' If it's not found then it must be a Space Character
' If it is found then convert the position to an ASCII Character
' in the range A to Z
' Add it to the decoded data
'
strChr = Mid$(strCoded, intI, 1)
intPos = InStr(strCode, strChr)
If intPos > 0 Then
intPos = intPos + Asc("A") - 1
strDecode = strDecode & Chr(intPos)
Else
strDecode = strDecode & " "
End If
Next intI
Text3.Text = strDecode
End Sub
Private Sub Form_Load()
strCode = "QAZWSXEDCRFVTGBYHNUJMIKOLP"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
I'll leave you to work out how to cope with numerics, punctuation and lower case letters. (It's not much fun for you if we do it all for you !)