单选题 VF
题号 #490068

在窗体上从左到右有Text1、Text2两个文本框(见图),要求程序运行时,Text1中输入1个分数后按回车键,则判断分数的合法性,若分数为0~100中的l个数,则光标移到Text2中;否则光标不动,并弹出对话框显示“分数错”。下面程序中正确的是
(  )
A.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAseii=13 Then’回车符的ASCIl码是l3
a =Va1(Text1)
If a>=00r a<=lOOThen
Text2.SetFocus
Else
Text1.SetFocus:MsgBox(”分数错”)
End If
End If
End Sub
B.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then’回车符的ASCIl码是l3
a=Va1(Text)
If a>=0And a<=100Then
Text1.SetFocus
Else
Text2.SetFocus:MsgBox (“分数错”)
End If
End If
End Sub
C.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then’回车符的ASCIl码是l3
a=Va1(Text1)
If a<0And a>100Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox(“分数错”)
End If
End If
End Sub
D.Private Sub Text1_KeyPress(KeyAscii As Integer)
IfKeyAscii=13 Then’回车符的ASCIl码是l3
a=Va1(Text1)
If a>=0And a<=lOOThen
Text2.SetFOCHS
Else
Text1.SetFocus:MsgBox(“分数错”)
End If
End If
End Sub

进入在线模考

参考答案

D

答案解析

判断数a为0-100之间的合法数的表达式为a>=0 and a<=100,该表达式为True,则a为合法数,否则不合法。要将光标移动到Text2中,可使用其SetFocus方法。所以,答案是D。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考