图a |
图b |
实现上述功能的VB程序如下,请回答下列问题。
Const n = 10
Dim a(1 To n) As Integer
Private Sub Command1_Click() '素数迁移模块
Dim i As Integer
List1.Clear '清除列表框
List2.Clear
For i = 1 To n
For j = 2 To a(i) - 1
If Then
Exit For 'Exit For的功能是退出For循环
End If
Next j
If Then
List2.AddItem Str(a(i))
Else
List1.AddItem Str(a(i))
End If
Next i
End Sub
Private Sub Form_Load() '随机数初始化模块
Randomize '随机数种子初始化
For i = 1 To n
a(i) =
List1.AddItem Str(a(i))
Next i
End Sub
小王利用VB程序实现这一加密功能,程序界面和代码如下所示:
Private Sub Com_ jm_ Click()
Dim x As String, ch As String, cl As String
Dim sl 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
① ② ③