VB程序设计:随机生成10个数据,用一维数组存放(默认下标从1开始),输出数组元素于一行,将该数组元素...

2024-12-03 17:18:48
推荐回答(1个)
回答1:

新建一个工程,在窗体上添加一个按钮,输入以下代码,运行点击按钮就可
Private a1&(1 To 10), a2&(1 To 10)
Private Sub Command1_Click()
Dim b1&, b2&
For b1 = 1 To 10
a1(b1) = Int(Rnd() * 100)
Print a1(b1);
Next
Print
For b1 = 10 To 1 Step -1
Print a1(b1);
Next
Print
Print "下标奇数:";
For b1 = 1 To 10 Step 2
Print a1(b1);
Next
Print
Print "下标偶数:";
For b1 = 2 To 10 Step 2
Print a1(b1);
Next
End Sub