#2
cwa99582023-08-28 07:51
|
我的问题已包含在图片里,先谢谢大家。
只有本站会员才能查看附件,请 登录
程序代码:
'动态数组重新定义redim语句练习
'选择符合要求的数据存入新数组并输出P127-6.4
Private Sub Form_Load()
Dim a() As Integer, b() As Integer
Show
ReDim a(201)
k = 0
For x = 100 To 200
If x Mod 8 = 0 Then
k = k + 1: a(k) = x
End If
Next x
ReDim Preserve a(k)
Print "100-200之间能被8整除的数有 " & k & " 个,分别是:"
For j = 1 To k
Print a(j);
Next j
Print: Print
''下面是以二维数组的形式输入-----------------------
ReDim b(2, 6)
Print "用二维数组显示为:"
For i = 1 To 2
For j = 1 To 6
If (i - 1) * 6 + j <= 13 Then '控制引用a数组的元素数目不要超过它的总个数;
b(i, j) = a((i - 1) * 6 + j)
Print b(i, j);
End If
Next j
Print
Next i
End Sub
'选择符合要求的数据存入新数组并输出P127-6.4
Private Sub Form_Load()
Dim a() As Integer, b() As Integer
Show
ReDim a(201)
k = 0
For x = 100 To 200
If x Mod 8 = 0 Then
k = k + 1: a(k) = x
End If
Next x
ReDim Preserve a(k)
Print "100-200之间能被8整除的数有 " & k & " 个,分别是:"
For j = 1 To k
Print a(j);
Next j
Print: Print
''下面是以二维数组的形式输入-----------------------
ReDim b(2, 6)
Print "用二维数组显示为:"
For i = 1 To 2
For j = 1 To 6
If (i - 1) * 6 + j <= 13 Then '控制引用a数组的元素数目不要超过它的总个数;
b(i, j) = a((i - 1) * 6 + j)
Print b(i, j);
End If
Next j
Next i
End Sub
[此贴子已经被作者于2023-8-26 21:12编辑过]