试题

试题 试卷

logo

题型:填空题 题类:常考题 难易度:困难

浙江省台州市书生中学2016-2017学年高二下学期信息技术第一次月考试卷

【加试题】小明编写了一个输出十进制与二进制数对应表的VB程序。程序运行时,单击“输出”按钮Command1后,在列表框List1中输出运行结果如图所示。实现上述功能的VB代码如下,但横线处代码有错,请改正。

Dim b(4) As Integer         '数组b按位存储二进制数,数组类型为整型,元素个数为4个

Private Sub pprint(m As Integer) 

'本过程打印输出一行十进制数m和对应的二进制数

'代码略

End Sub

Private Sub Command1_Click()

  Dim i As Integer, j As Integer                                        

  List1.Clear                                                               

  List1.AddItem "十进制数      二进制数"                          

  For i = 1 To 4                                          

      b(i) = 0                                                   

  Next i

  For i = 0 To 15                                    

      Call pprint(i)                                    

      j =   1                '(1)         

      b(j) = b(j) + 1                  

      Do While  b(j) = 0     '(2)  

         b(j) = 0                            

         j = j - 1                          

         b(j) = b(j) + 1              

      Loop                                  

  Next i                                

End Sub

 ⑵ 

举一反三
返回首页

试题篮