题库 高中信息

题干

用 VB 编写统计某字母开头的单词个数的程序。程序功能:在文本框 Text1 中输入待统计的句子,在文本框 Text2 中输入某字母,单击“统计”按钮Command1后,将结果显示在Label3中。输入要求:句子以“.”结束;单词之间用空格分隔,单词没有缩写或其他特殊形式。程序运行界面如图所示:

Private Sub Command1_Click()
Dim i As Integer, n As Integer,b As Integer
Dim c As String, t As String, s As String, f As Boolean
s = Text1.Text
t = Text2.Text
b = Len(s)
f = True
For i = 1 To b
c = Mid(s, i, 1)
If  ① Then
n = n + 1
② 
ElseIf c = " " Or c = "." Then
③          
Else
f = False
End If
Next i
Label3.Caption = "以" + t + "为开头的单词个数:" + Str(n)
End Sub
为实现上述程序,空格处应填入的代码是(   )
A.① f And c = t ② f = False     ③ f = True
B.① f = False And c = t   ② f = False     ③ f = True
C.① c = t     ② f = True   ③ f = False
D.① f = True And c = t   ② f = True ③ f = False
上一题 下一题 0.99难度 选择题 更新时间:2019-07-10 02:39:21

答案(点此获取答案解析)