全部题库 / VB / 试题详情
单选题 VB
2008-03-18

在窗体上从左到右有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

参考答案

D

答案解析

暂无解析

你可能感兴趣的试题