问题 单项选择题

在窗体上画一个名称为Text1的文本框,要求文本框只能接收大写字母的输入,以下能实现该操作的事件过程是______。

A.Private Sub Text1_KeyPress(KeyAscii As Intege If KeyAscii<65 Or KeyAscii>90 Then MsgBox"请输入大写字母" KeyAscii=0 End If End Sub

B.Private Sub Text1_KeyDown(Keycode As Integer, Shift As Intege If KeyCode<65 Or Keycode>90 Then MsgBox"请输入大写字母" KcyCode=0 End If End Sub

C.Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Singl If Asc(Text1. Tex<65 Or Asc(Text1. Tex>90 Then MsgBox"请输入大写字母" End If End Sub

D.Private Sub Text1_Change() If Asc(Text1. Tex>64 Or Asc(Text1. Tex<91 Then MsgBox"请输入大写字母" End If End Sub

答案

参考答案:A

解析:[分析] 当在文本框Text1中输入字符时,会激活Text1_KeyPress、Text1_KeyDown和Text1_Change过程,选项C是错误的;KcyDown事件中所得到的KeyCode码(KeyDown事件的参数)65与按字母键“a”是相同的,不能符合题意,选项B是错误的;条件“Asc(Text1. Text)>64 Or Asc(Text1. Text)<91”满足字母大写的要求,不符合题意,选项D是错误的;选项A是正确的。

选择题
填空题