我真是小白,哪位大佬出手相助
随机产生10个50以内的正整数,从大到小排序,并显示排序前和排序后的结果。
Dim AA(1 To 10) As Integer, BB(1 To 10) As Integer Private Sub Command1_Click() For I = 1 To 10 BB(I) = AA(I) Next I Dim KK As Integer For I = 1 To 9 For J = 1 To 10 - I If BB(J) > BB(J + 1) Then KK = BB(J) BB(J) = BB(J + 1) BB(J + 1) = KK End If Next J Next I Text2.Text = "" For I = 1 To 10 If BB(I) < 10 Then Text2.Text = Text2.Text & "0" & CStr(BB(I)) & Space(5) Else Text2.Text = Text2.Text & CStr(BB(I)) & Space(5) End If Next I End Sub Private Sub Command2_Click() Unload Me Form1.Show End Sub Private Sub Form_Load() For I = 1 To 10 Randomize AA(I) = Int(Rnd * 50 + 1) Next I Text1.Text = "" For I = 1 To 10 If AA(I) < 10 Then Text1.Text = Text1.Text & "0" & CStr(AA(I)) & Space(5) Else Text1.Text = Text1.Text & CStr(AA(I)) & Space(5) End If Next I End Sub