[vb]代码库
Option Explicit
Option Base 1
Dim i As Integer
Dim j As Integer
Dim a() As Integer
Dim n As Integer
Private Sub Command1_Click()
Text3.SetFocus
n = Val(Text3)
ReDim a(n, n) '动态数组
For i = 1 To n
For j = 1 To n
a(i, j) = Int(10 * Rnd + 0) '随机数
Text1 = Text1 & a(i, j) & " " '一行
Next j
Text1 = Text1 & Chr(13) & Chr(10) '多行
Next i
End Sub
Private Sub Command2_Click()
Dim b() As Integer
n = Val(Text3)
ReDim b(n, n)
For i = 1 To n
For j = 1 To n
b(i, j) = a(j, i) '转置
Text2 = Text2 & b(i, j) & " " '一行
Next j
Text2 = Text2 & Chr(13) & Chr(10) '多行
Next i
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = "" '清除
Text3.SetFocus
End Sub
Private Sub Command4_Click()
End '结束
End Sub
Private Sub Form_Load()
Text1 = ""
Text2 = ""
Text3 = "" '清除
End Sub