二级VB参考书第10章自测题
1.编写如下两个事件过程: Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Print Chr(KeyCode) End Sub Private Sub Form_KeyPress(KeyAscii As Integer) Print Chr(KeyAscii) End Sub 在一般情况下(即不按住Shift键和锁定大写),运行程序,如果按“A”键,则程序的输出是 A.A B.a C.A D.a a A A a 2. "在窗体上画一个命令按钮和一个文本框,并把窗体的KeyPreview属性设置为True,然后编写如下代码: Dim SaveAll As String Private Sub Form_Load() Show Text1.Text = "" Text1.SetFocus End Sub Private Sub Command1_Click() Text1.Text = UCase(SaveAll) End Sub Private Sub Form_KeyPress(KeyAscii As Integer) SaveAll = SaveAll + Chr(KeyAscii) End Sub 程序运行后,在键盘上输入 abcdefg,单击命令按钮,则文本框中显示的内容为 A.abcdefg B.不显示任何信息 C.ABCDEFG D.出错 3. 在上题中,如果把窗体的KeyPreview属性设置为False,则文本框中显示的内容为 A.abcdefg B.不显示任何信息 C.ABCDEFG D.出错 4. "在窗体上画一个文本框,然后编写如下事件过程: Private Sub Text1_KeyPress(KeyAscii As Integer) Dim char As String char = Chr(KeyAscii) KeyAscii = Asc(UCase(char)) Text1.Text = String(6, KeyAscii) End Sub 程序运行后,如果在键盘上输入字母“a”,则文本框中显示的内容为 A.a B.A C.aaaaaa D.AAAAAA 5. 把窗体的KeyPreview属性设置为True,然后编写如下过程: Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Print Chr(KeyCode) End Sub Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) Print Chr(KeyCode + 2) End Sub 程序运行后,如果按“A”键,则输出结果为 A.A B.A C.A D.A A B C D 首页 1 2 尾页 相关资料 |