试题

试题 试卷

logo

题型:单选题 题类:常考题 难易度:普通

浙江省台州中学2014-2015学年高一下学期信息技术期中考试试卷

小明编写了如下VB程序段:

Private Sub Command1_Click()

  Dim x As Double

  Dim y As Double

  x = Val(Text1.Text)

  y = Abs(x)

  x = int(y)

  Text2.Text = Str(x)

End Sub

此应用程序执行后,出现了如图所示的错误信息,请问产生此错误的原因是(   )

A、语句y = Abs(x)有误 B、缺少对象‘424’ C、语句x = int(y)有误 D、缺少文本框Text1或文本框Text2
举一反三
编写VB程序,功能为:单击“发牌”按钮“Command1”后,从一副扑克牌(不包括大王、小王、J、Q、K、A)中随机抽取5张牌,牌的花色(♠♥♣♦)忽略,显示在列表框“List1”中。如果这5张牌由一个对子和一个顺子(3张牌连续)组成,则在标签“Label1”中显示“运气不错:)”,否则显示“运气一般:|”。程序运行界面如图所示。

实现上述功能的VB程序如下:

Private Sub Command1_Click()

  List1.Clear

  Dim five(1 To 5) As Integer

  Dim i As Integer, j As Integer, k As Integer

  Dim p As Integer, find_pair As Boolean

  '随机抽取5张牌,将牌的点数存储在数组five中,并在List1中显示。代码略

  i = 5: p = 1: find_pair = False

  Do While i>= 2

    j=p

    Do While j <= i - 1

      If five(j) > five(j + 1) Then

        t = five(j): five(j) = five(j + 1): five(j + 1) = t

      ElseIf five(j) = five(j + 1) And Not find_pair Then

        t = five(1): five(1) = five(j): five(j) = t

        t = five(2): five(2) = five(j + 1): five(j + 1) = t

        find_pair = True

        i = i + 1

        p = _____________

        Exit Do

      End If

      j = j + 1

    Loop 

    i = i - 1

  Loop

  k = 0

  For i = 3 To 4

    If  Then k = k + 1

  Next i

  If five(1) = five(2) And k = 2 Then

    Label1.Caption = "运气不错:)"

  Else

    Label1.Caption = "运气一般:|"

  End If

End Sub

请回答下列问题:

返回首页

试题篮