编写VB程序,实现如下功能:在程序运行时,在文本框1中输入整数m(1≤m≤10),单击“生成矩阵”按钮Command1,生成m2个范围为[0,9]的随机整数,随机存储在数组a中,并以m行、m列矩阵的形式在列表框List1上显示。单击“行排序”按钮Command2,对矩阵以“行”为单位完成升序排序,并在列表框List2上显示。运行界面如图所示,程序代码如下:
Dim m As Integer
Dim a(1 To 100) As Integer
Private Sub Command1_Click()
'输入整数m,并随机产生m2个随机数
'随机数以m*m 矩阵形式在List1上显示
'代码略
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer ,t As Integer, k As Integer,
Dim s As String
List2.Clear
For i = 1 To m * m
k = i
For j = i + 1 To ①
If a(j) < a(k) Then k = j
Next j
If k <> i Then t = a(k): a(k) = a(i): a(i) = t
②
If Then
List2.AddItem s
s = ""
End If
Next i
End Sub