vb 4行5列生成的随机数组,求每行和每列的值
要求行和显示在每行的后面,每列和显示在每列下面随机数组在图片框里,行列和分别在2个text里如图...
要求行和显示在每行的后面,每列和显示在每列下面
随机数组在图片框里,行列和分别在2个text里
如图 展开
随机数组在图片框里,行列和分别在2个text里
如图 展开
1个回答
展开全部
建立一个文本框Text1设置multiline=true scrollbars=2再添加一个图片框和另一个文本框Text2
点击图片
Private Sub Picture1_Click()
Dim i As Integer, j As Integer, a(0 To 3, 0 To 4) As Double, Sum As Double
For i = 0 To 3
For j = 0 To 4
Randomize
a(i, j) = Int(Rnd() * 100)
Picture1.Print a(i, j) & vbTab;
Next
Picture1.Print
Next
Text1.Text = ""
Text2.Text = ""
For i = 0 To 3
Sum = 0
For j = 0 To 4
Sum = Sum + a(i, j)
Next
Text1.Text = Text1.Text & Sum & vbNewLine
Next
For i = 0 To 4
Sum = 0
For j = 0 To 3
Sum = Sum + a(j, i)
Next
Text2.Text = Text2.Text & Sum & vbTab
Next
End Sub
点击图片
Private Sub Picture1_Click()
Dim i As Integer, j As Integer, a(0 To 3, 0 To 4) As Double, Sum As Double
For i = 0 To 3
For j = 0 To 4
Randomize
a(i, j) = Int(Rnd() * 100)
Picture1.Print a(i, j) & vbTab;
Next
Picture1.Print
Next
Text1.Text = ""
Text2.Text = ""
For i = 0 To 3
Sum = 0
For j = 0 To 4
Sum = Sum + a(i, j)
Next
Text1.Text = Text1.Text & Sum & vbNewLine
Next
For i = 0 To 4
Sum = 0
For j = 0 To 3
Sum = Sum + a(j, i)
Next
Text2.Text = Text2.Text & Sum & vbTab
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询