试题

试题 试卷

logo

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

内蒙古巴彦淖尔市临河三中计算机班2018-2019高二下学期信息技术期中考试试卷VB

在窗体上画一个命令按钮,其Name属性为Command1,然后编写如下代码:

Option Base 1

Private Sub Command1Click

     Dim a(4, 4)

     For i = 1 To 3

        For j = 1 To 3

             a(i, j)=(i-1)*3+j

        Next j

     Next i

     PRINT A(3, 1)

End Sub

程序运行后,单击命令按钮,其输出结果为(  )

A、6 B、7 C、8 D、9
举一反三
下列VB程序实现数字字母混合序列分离后分别排序,最后又合并输出。具体算法如下:在文本框Text1输入若干组混合序列,每组序列中仅包含一组字母和一个多位数字,序列之间用逗号隔开,以逗号结束。单击“排序”按钮command1,把每组序列中的字母和数字分开,并分别排序,最后在列表框list1输出。排序规则如下:所有数字按从小到大升序排序,字母序列按长度升序排序,若长度相同,直接按字母序列大小升序排序(按字母的ASCII码排序,“A”<“Z”<“a”<“z”)。实现算法的部分程序界面如图所示,VB程序代码如下,回答下列问题:

Private Sub Command1_Click()

Dim a(1 To 6) As Integer, b(1 To 6) As String, i as integer, j as integer

Dim c As String, k As Integer, tmp1 As Integer, tmp2 As String

s=text1.text

i = 1: k = 1: tmp1 = 0: tmp2 = ""

Do While i <= Len(s)

      c = Mid(s, i, 1)

      If c = "," Then

         a(k) = tmp1: b(k) = tmp2

         tmp1 = 0: tmp2 = ""

              ①    

      Else

        If  Then 

           tmp2 = tmp2 + c

        Else

         tmp1=tmp1*10+val(c)

        End If

      End If

      i = i + 1

    Loop

    For i = 1 To 5

      For j = 1 To 6 - i

        If a(j) > a(j + 1) Then tmp1 = a(j): a(j) = a(j + 1): a(j + 1) = tmp1

    If Len(b(j)) > Len(b(j + 1)) Or      ②       Then

          tmp2 = b(j): b(j) = b(j + 1): b(j + 1) = tmp2

        End If

      Next j

    Next i

    For i = 1 To 6

      List1.AddItem Str(a(i)) + b(i)

    Next i

    End Sub

返回首页

试题篮