填空题
VB
题号 #453464
在窗体上画一个名为Command1的命令按钮,编写如下程序:
Private Sub Command1_Click()
DimnOAs Integer
Dim a As Integer,b As Integer
a=InputBox(”Enter the first number”)
b=InputBox(”Enter the second number”1
ReDimn(aTob)
For k=LBound(n,1)To UBound(n,1)
n(k)=k
Print“n(“;k;”)=”;n(k)
Next
End Sub
程序运行后,单击命令按钮,在输入对话框中分别输入4和5,则输出结果为________。
参考答案
暂无
答案解析
n(4)=4;n(5)=5
本题考查了数组的定义。程序中首先用Dim语句定义了一个没有下标的数组,然后由用户通过输入对话框来指定数组的上下标,并用ReDim语句重新定义数组。最后通过For循环给数组赋值并输出。
本题考查了数组的定义。程序中首先用Dim语句定义了一个没有下标的数组,然后由用户通过输入对话框来指定数组的上下标,并用ReDim语句重新定义数组。最后通过For循环给数组赋值并输出。