VB告急在线等参照下图,将一个由3位不同随机正整数构成的6×6二维数组置于图片框pic1中,编写程序:(1)求二维数组每

1个回答

  • Dim a(1 To 6, 1 To 6) As Integer'代码给你,设置的你自己设置吧,按钮名称从上到下依次是command1至command6

    Private Sub Command1_Click()

    For i = 1 To 6

    For j = 1 To 6

    Randomize

    a(i, j) = Int(Rnd * 900 + 100)

    Pic1.Print a(i, j);

    Next j

    Pic1.Print

    Next i

    End Sub

    Private Sub Command2_Click()

    Dim s As Integer

    Text1.Text = ""

    For i = 1 To 6

    s = 0

    For j = 1 To 6

    s = s + a(i, j)

    Next j

    Text1.Text = Text1.Text & Str(s) & vbCrLf

    Next i

    End Sub

    Private Sub Command3_Click()

    Dim s As Integer

    Text2.Text = ""

    For i = 1 To 6

    s = 0

    For j = 1 To 6

    s = s + a(j, i)

    Next j

    Text2.Text = Text2.Text & Str(s)

    Next i

    End Sub

    Private Sub Command4_Click()

    Dim s As Integer

    For i = 1 To 6

    s = s + a(i, i) + a(i, 7 - i)

    Next i

    Label1.Caption = "曹婷婷求得该数组两条对角线上所有元素之和为:" & Str(s)

    End Sub

    Private Sub Command5_Click()

    Pic1.Cls

    Text1.Text = ""

    Text2.Text = ""

    Label1.Caption = ""

    End Sub

    Private Sub Command6_Click()

    End

    End Su