单选题
VF
题号 #490071
在窗体上画1个文本框,其名称为Text1,然后编写如下过程:
Private Sub Text1_KeyDown(KeyCode As Integer,shift As Integer)
Print Chr(KeyCode)
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer,shift As Integer)
Print Chr(KeyCode+2)
End Sub
程序运行后,把焦点移到文本框中,此时如果敲击“A”键,则输出结果为( )
参考答案
C
答案解析
将焦点移动到文本框中,敲击“A”键,将先后触发文本框的KeyDown、KeyUp事件。KeyCode是按键的实际AscIl码值,所以,KeyDown事件过程中打印“A”C-符、KeyUp事件过程中打印“C”字符,答案是C。
你可能感兴趣的试题
A.A
B.B
C.C
D.D
A.在KeyPress事件过程中不能识别键盘的按下与释放
B.在KeyPress事件过程中不能识别回车键
C.在KeyDown和KeyUp事件过程中,将键盘输入的“A”和“a”视作相同的字母
D.在KeyDown和KeyUp事件过程中,从大键盘上输入的“1”和从右侧小键盘上输入的“1”被视作不同的字符
A.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii<65 0r KeyAscii>90 Then
MsgBox”请输入大写字母”
KeyAscii=0
End If
End Sub
If KeyAscii<65 0r KeyAscii>90 Then
MsgBox”请输入大写字母”
KeyAscii=0
End If
End Sub
B.Private Sub Text1_KeyDown(KeyCode As Integeq Shift As Integer)
If KeyCode<65 0r KeyCode>90 Then
MsgBox“请输入大写字母”
KeyCode=0
End If
End Sub
If KeyCode<65 0r KeyCode>90 Then
MsgBox“请输入大写字母”
KeyCode=0
End If
End Sub
C.Private Sub Text1_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single)
If Asc(Text1.Text)<65 0r Asc(Text1.Text)>90 Then
MsgBox“请输入大写字母”
End If
End Sub
If Asc(Text1.Text)<65 0r Asc(Text1.Text)>90 Then
MsgBox“请输入大写字母”
End If
End Sub
D.Private Sub Text1_Change()
If Asc(Text1.Text)>64 And Asc(Text1.Text)<91 Then
MsgBox“请输入大写字母”
End If
End Sub
If Asc(Text1.Text)>64 And Asc(Text1.Text)<91 Then
MsgBox“请输入大写字母”
End If
End Sub