[单项选择题] 在窗体中添加两个文本框,其名称分别为Text1和Text2;两个标签,其名称分别为Label1和Label2。编写程序,使得程序运行后,在文本框Text2中输入小写字母,能转换为比此字

20 查阅

[单项选择题] 在窗体中添加两个文本框,其名称分别为Text1和Text2;两个标签,其名称分别为Label1和Label2。编写程序,使得程序运行后,在文本框Text2中输入小写字母,能转换为比此字母的ASCII码小4的大写字母,结果显示在文本框Text1中。如输入“efg”,则输出的结果为“ABC”,能够实现上述功能的程序是

A.Private Sub Form Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_KeyDown(KeyCode As Integer,Shift As Intege Text1.Text=Chr(KeyCode-4)End Sub

B.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_KeyDown(KeyCode As Integer,Shift As Intege Text1.Text=Text1.Text+Chr(KeyCode-4)End Sub

C.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_Click(KeyCode As Integer,Shift As Intege Text1.Text=Text1.Text+Chr(KeyCOde-4)End Sub

D.Private Sub Form_Load() Show Text1.Text=" " Text2.Text=" " Text2.SetFocusEnd SubPrivate Sub Text2_Click(KeyCode As Integer,Shift As Intege Text1.Text=Chr(KeyCode-4)End Sub

参考答案:

B

[分析] 当在文本框Text2中输入小写字母时,能触发的是KeyDown事件,而不能触发Click事件,所以选项C和D是错误的。选项A的文本框中每次只能显示一个字符,而选项B是正确的答案。

计算机考试