当前位置: 高中信息技术 / 综合题
  • 1. (2023高一上·云南期末) 统计不同单词个数,在Text1中输入一行单词,点击“统计”按钮后在Text2中输出不同单词的个数。单词字母有大小写,同一单词的大小字母视为相同,句子以符号结尾, 程序运行界面如图所示。

    1. (1) 观察以下代码,该代码中 Command1_Click()是 (选:A .对象名 /B .事件名 /C .事件处理过程名)
    2. (2) 实现上述功能的VB程序如下,请在划线处填入合适代码。

      Private Sub Command1_Click()

          Dim a(1 To 100) As String ,s As String, ch As String, word As String

          Dim i As Integer, j As Integer, k As Integer, numb As Integer

          s = Text1.Text :  k = 0 :  word = ""

          For i = 1 To Len(s)

              ch = Mid(s, i, 1)

              If ch >= "a" And ch <= "z" Or ch >= "A" And ch <= "Z" Then

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

                      word = word + ch

                  Else

                      flag = False

                      For j = 1 To k

                          If a(j) = word Then flag = True

                      Next j

                  If Not flag And word <> "" Then

                      

                      a(k) = word

                      numb = numb + 1

                  End If

                  

              End If

          Next i

          Text2.Text = str(numb)

      End Sub

微信扫码预览、分享更方便