题库 高中信息

题干

用 VB 编写“检查句子格式”的程序,实现如下功能:在文本框 Text1 中输入要检查的英文句子,单击“检查”按钮 Command1。判断句子“”和“?”后的字母是否是大写,如果是小写字母,那么将其转换为大写字母,并在文本框 Text2 中输出。程序运行界面如下图所示。 
(1)要使程序运行时,文本框 Text1 的 Height 属性值为 900,可在 Form_Load 事件处理过程中添加语句________(单选,填字母:
A.Height=900 /B.Textl. Height = 900 /C.Height. Textl=900)。
(2)实现上述功能的 VB 程序如下,请在划线处填入合适的代码。
Private Sub
Command1_Click()
Dim s As String, ch As String, flag As Boolean Dim ch2 As String, res As String, i As Integer s = Text1.Text: res = ""
______________ 
Do While i <= Len(s)
flag = False
ch = Mid(s, i, 1)
If i = 1 And ch >= "a" And ch2 <= "z" Then
ch = Chr(Asc(ch) - 32)    '小写字母转换为大写字母
End If
If ch = "." Or ch = "?" Then flag = True
ch2 = Mid(s, i + 1, 1)
If flag And ch2 >= "a" And ch2 <= "z" Then
ch2 = Chr(Asc(ch2) - 32) '小写字母转换为大写字母
res =_________________   
i = i + 2
Else
i = i + 1
res = res + ch
End If Loop
Text2.Text = res End Sub
(3)若在文本框 Text1 中输入句子:“you are best.”,第 1 个单词前有空格,则经过上述程序处理后,输出结果首字母“y”是否会变为大写“Y”?_____________(选填:是/ 否)。
上一题 下一题 0.99难度 填空题 更新时间:2019-05-28 08:39:41

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