解:
Private Sub cmdCode_Click()
Dim pt As String ' 明文
Dim ct As String ' 密文
Dim n As Integer ' 字母在字母表中的序号
Dim ch As String
Dim i As Integer
pt = txtPt.Text
ct = ""
For i = 1 To Len(pt)
ch = Mid(pt, i, 1)
Select Case ch
Case "A" To "Z"
n = Asc(ch) - Asc("A")
n = (n + 3) Mod 26
ch = Chr(n + 65)
Case "a" To "z"
n = asc(ch)-asc("A")
n = (n + 3) Mod 26
ch = Chr(n + 97)
End Select
ct = trim(ct & ch)
Next i
txtCt.Text = ct
End Sub