下列过程的功能是:在对多个文本框进行输入时,对第1个文本框(text1)输入完毕后用回车键使焦点跳到第2个文本框(text2),而不是Tab键来切换。请完成该程序。
Private Sub Textl_(eyDown(Keycode As Integer,Shift As Integer)
If [14] Then
Text [15]
End If
End Sub
第1题:
在窗体上从左到右有Text1、Text2两个文本框(见图),要求程序运行时,在Text1中输入1个分数后按回车键,则判断分数的合法性,若分数为0~100中的1个数,周围光标移到Text2中;否则光标不动,并弹出对话框显示“分数错”,下面程序中正确的是( )。
A.Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 or a<=100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
B.Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Text1.SetFocus
Else
Text2. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
C.Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a<0 And a>100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
D.Private Sub Text1__KeyPress(KeyAscii AS Integer)
If KeyAscii=13 Then ‘回车符的ACSII码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Text2.SetFocus
Else
Text1. SetFocus ; MsgBox(“分数错”)
End If
End If
End Sub
第2题:
( 29 )在窗体上画 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> 键,则输出结果为( )。
A ) A
A
B ) A
B
C ) A
C
D ) A
D
第3题:
窗体上有名称分别为Text1、Text2的2个文本框,要求文本框Text1中输入的数据小于500,文本框Text2中输入的数据小于1000,否则重新输入。为了实现上述功能,在以下程序中问号(?)处应填入的内容是。
Private Sub Text1_LostFocus()
Call CheckInput(Text1,500)
End Sub
Private Sub Text2_LostFocus()
Call CheckInput(Text2,1000)
End Sub
Sub CheckInput(t As ?,x As Integer)
If Val(t.Text)>x Then
MsgBox"请重新输入!"
End If
End Sub
A.Text
B.SelText
C.Control
D.Form
该题考查内容为控件参数。在一个通用过程中设置相同性质控件所需要的属性,然后用不同的控件调用此过程。
第4题:
若要求在图6-16窗口中,用户输入月工资(或薪金收入)后,直接按回车键或向下方向箭就能使焦点(当前光标)跳到应扣除的基本费用的输入文本框,而不用【Tab】键进行切换。请将以下文本框ht_salary的KeyDown(按键)事件过程中空缺的程序代码填写完整。
If KeyCode =13 Or KeyCode = 40 Then
(6)
End If
第5题:
在窗体上画1个文本框,其名称为Text1,然后编写如下过程: Pfivme 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”键,则输出结果为______。
A.A A
B.A B
C.A C
D.A D
第6题:
( 28 ) 窗体上有名称分别为 Text1 、 Text2 的 2 个文本框 , 要求文本框 Text1 中输入的数据小于 500 , 文本
框 Text2 中输入的数据小于 1000 ,否则重新输入。为了实现以上功能,在下列程序中问号( ? )处
应填入的内容是( )。
Private Sub Text1_LostFocus( )
Call CheckInput(Text1,500)
End Sub
Private Sub Text2_LostFocus( )
Call CheckInput(Text2,1000)
End Sub
Sub CheckInput(t As ?,x As Integer)
If Val(t.Text)>x Then
MsgBox" 请重新输入 !"
End If
End Sub
A ) Text
B ) SelText
C ) Control
D ) Form
第7题:
窗体上有名称分别为Text1、Text2的2个文本框,要求文卒框Text1中输入的数据小于500,文本框Text2中输入的数据小于1000,否则重新输入。为了实现上述功能,在以下程序中问号(?)处应填入的内容是______。 Private Sub Text1 LostFocus() Call CheckInput(Text1,500) End Sub Private Sub Text2 LostFocus() Call CheCkInput(Text2,1000) End Sub Sub CheckInput(t AS ?,x As Integer) If Val(t.Text)>X Then MsgBox "请重新输入!" End If End Sub
A.Text
B.SelText
C.Control
D.Form
第8题:
在窗体上画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”键,则输出结果为。
A.A
A
B.A
B
C.A
C
D.A
D
KeyDown和KeyUp都有两个参数,即KeyCode和Shift,KeyCode是按键的实际ASCII码,Shift是转换键。Chr函数为求ASCII字符,而ASC(C)=ASC(A)+2。因此输出结果应该为A与C。
第9题:
如图所示,在列表框List1中已经有若干人的简单信息,运行时在Text1文本框(即“查找对象”右边的文本框)输入一个姓或姓名,单击“查找”按钮,则在列表框中进行查找,若找到,则把该人的信息显示在Text2文本框中。若有多个匹配的列表项,则只显示第1个匹配项;若未找到,则在Text2中显示“查无此人”。请填空。
Private Sub Command1_Click()
Dim k As Integer, n As Integer, found As Boolean
found = False
n = Len(【14】 )
k = 0
While k < List1.ListCount And Not found
If Text1 = Left$(List1.List(k), n) Then
Text2 = 【15】
found = True
End If
k = k + 1
Wend
If Not found Then
Text2 = "查无此人"
End If
End Sub
text1.text list1.list(k)
第10题:
(17)窗体上添加了一个文本框Text1,编写下列代码: Private Sub Text1_KeyDown(KeyCode As Integer,Shift As Integer) Print Chr(KeyCode+5)&KeyCode End Sub 程序运行时,在文本框中输入“ab”则在窗体上输出为 A.F65 G66 B.F65 F65 C.G66 F65 D.G65 G66