中国大学MOOC: 下面程序片段中有错误:Sub pric() Public x As Integer x = Array(1, 2, 3, 4, 5) ……End Sub为了避免出错,正确的修改方案是_______________。
举一反三
- 下面程序片段中有错误:Sub pric() Public x As Integer x = Array(1, 2, 3, 4, 5) ……End Sub为了避免出错,正确的修改方案是_______________。 A: 把Public x As Integer 改为Public x As Variant B: 把Public x As Integer 改为Dim x(5) C: 把Public x As Integer 改为Static x D: 把x = Array(1, 2, 3, 4, 5)改为x = Array(0, 1, 2, 3, 4)
- 设有下面程序 Sub inc(a As Integer) Static x As Integer x = x + a Print x; End Sub Private Sub Form_Click() inc 2 inc 3 inc 4 End Sub 程序运行后,单击命令按钮 Command1 ,则输出的结果是________
- 在窗体上画一个命令按钮,然后编写如下程序: Private Sub Comrnand3_Click( ) Cop 2 Cop 3 Cop 4 End Sub Sub Cop (a As Integer) Static x As Integer x=x + a Print x; End Sub 程序运行后,单击命令按钮,输出结果为 A: 2 3 4 B: 2 5 9 C: 3 5 4 D: 2 4 3
- 如下程序的运行结果是【1】. Private Sub Command1_Click() Dim x As Integer x = 12 f2 x Print x End Sub Public Sub f2(n As Integer) n = n Mod 10 End Sub
- 设窗体上有一个Command1命令按钮,还有以下程序代码: Private Sub Command1_Click() Static x As Integer x=x+1 Call proc(x) Print x, End Sub Private Sub proc(a As Integer) Static x As Integer x=x+a:a=x End Sub 程序运行后,3次单击命令按钮,则产生的输出是 A: 1 2 3 B: 1 3 5 C: 1 3 7 D: 2 4 6