对一段字符(仅包含大小写字母和数字)加密,加密规则为:①字母和数字都往后循环顺移3位,如“a”变为“d”,“y”变为“b”;“0”变为“3”,“7”变为“0”②加密后字母在前,数字在后③字母按逆序排列,数字按顺序排列,如输入明文“ab7Z8x3”,这密文为“aCed4016”。
小王利用VB程序实现这一加密功能,程序界面和代码如下所示:
Private Sub Com_ jm_ Click()
Dim x As String, ch As String, cl As String
Dim s1 As String, s2 As String, s As String
Dim i As Integer, n As Integer, y As Integer
x= Text1. Text
n=Len(x)
For i=1 To n
ch= Mid(x, i, 1)
If ch >= "0" And ch <= "9" Then
①
s2=s2 & y
Elself ch >="a" And ch<="z" Then
y=(Asc(ch)-Asc("a")+3) Mod 26
②
s1=c1+s1
Else
y=(Asc(ch)- Asc("A")+3) Mod 26
c2=Chr(Asc("A")+y)
s1=c2+s1
End If
Next i
③
Text2 Text=s
End sub