试题

试题 试卷

logo

题型:综合题 题类:模拟题 难易度:普通

浙江省2019年信息技术选考模拟试卷一

编写VB程序,实现如下功能:单击“生成密文”按钮Command1,在文本框Text2中产生与每个小写字母对应的密文(每个明文字母对应1个不重复的密文字母)。在文本框Text3中输入单词字符串,单击“加密”按钮Command2后,进行逐个字符加密,加密方法:在“明文”中找到相应字符,再得到明文对应位置的密文,并在文本框Text4中显示对应密文(运行效果如图所示)。

(1)、如图所示,则英文“eduction”加密后的密文是
(2)、实现上述功能的VB代码如下,请在划线处填入合适的代码。

Dim m2 As String

Private Sub Command1_Click()

Dim flag(1 To 26) As Boolean

Dim num As Integer,t As Integer

num = 1

For i = 1 To 26

    flag(i) = False

Next i

Do While num <= 26

    x = Int(Rnd * 26) + 97

         ①       

    If  flag(t) = False Then

        m2 = m2 + Chr(x)

        num = num + 1

           ②      

    End If

Loop

Text2.Text = m2

End Sub

Private Sub Command2_Click()

Dim s As String, m As String, result As String

Dim k As String, c As Integer

s = Text3.Text : m = Text1.Text

For i = 1 To Len(s)

    k = Mid(s, i, 1)

    If  k >= "A" And k <= "Z"  Then

        k = Chr(Asc(k) + 32)

    End If

    c = 1 : continue = True

    Do While continue=True

        If k = Mid(m, c, 1) Then

          continue = False

        End If

        c = c + 1

    Loop

      ③     

Next i

Text4.Text = result

End Sub

以上程序段运行时,为了实现上述功能,划线处应填入的代码为为:

; ② ;③

返回首页

试题篮