来请教一下vb的题目,题目如下
vb吧
全部回复
仅看楼主
level 1
旧时光Mars 楼主
2022年06月18日 17点06分 1
level 15
'求所有元素和的函数
Private Function Sum1(a() As Integer) As Integer
Dim i As Integer, j As Integer
For i = LBound(a, 1) To UBound(a, 1)
For j = LBound(a, 2) To UBound(a, 2)
Sum1 = Sum1 + a(i, j)
Next j
Next i
End Function
'求不靠谱([滑稽])元素和的函数
Private Function Sum2(a() As Integer) As Integer
Dim i As Integer, j As Integer
For i = LBound(a, 1) + 1 To UBound(a, 1) - 1
For j = LBound(a, 2) + 1 To UBound(a, 2) - 1
Sum2 = Sum2 + a(i, j)
Next j
Next i
End Function
'“运行”按钮的代码,调用以上两个函数完成计算
Dim a(1 To 5, 1 To 5) As Integer
Dim i As Integer, j As Integer
Randomize
For i = 1 To 5
For j = 1 To 5
a(i, j) = Int(Rnd * 9) + 1
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
Text1.Text = Sum1(a)
Text2.Text = Sum2(a)
2022年06月19日 03点06分 2
感谢🙏大佬!!!
2022年06月19日 19点06分
1