2007年4月全国计算机等级考试二级VB语言笔试全真试题及答案
来源:优易学  2011-11-20 15:12:23   【优易学:中国教育考试门户网】   资料下载   IT书店

  (34)在窗体上从左到右有Text1、Text2两个文本框(见图),要求程序运行时,在Text1中输入1个分数后按回车键,则判断分数的合法性,若分数为0~100中的1个数,周围光标移到Text2中;否则光标不动,并弹出对话框显示“分数错”,下面程序中正确的是(D)
  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

  (35)在窗体上画2个命令按钮,名称分别为Command1、command2,并编写如下程序
   Const n=5,m=4
   Dim a(m,n)
   Private Sub Command1_Click()
   K=1
   For i=1 To m
   For j=1 To n
   a(i,j)=k
   k=k+1
   Next j
   Next i

  Private Sub Command2_Click()
   Summ=0
   For i=1 To m
   For j=1 To n
   If i=1 Or i=m Then
   Summ=summ+a(i,j)
   Else
   If j=I Or j=n Then
   Summ=summ+a(i,j)
   End If
   End If
   Next j
  Next i
  Print summ
  End Sub <

上一页  [1] [2] [3] [4] [5] [6] [7] [8] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训