1
Dim a(1 To 10) As Integer
Private Sub Command1_Click()
For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then
b = a(i): a(i) = a(j): a(j) = b
End If
Next j
Next i
Text2.Text = ""
For i = 1 To 10
Text2 = Text2 & Str(a(i))
Next i
End Sub
Private Sub Form_Load()
Randomize
Text1.Text = ""
For i = 1 To 10
a(i) = Int(Rnd * 90 + 10)
Text1 = Text1 & Str(a(i))
Next i
End Sub
Option ExplicitDim s(9) As Long
Private Sub Command1_Click()
Dim i As Long
For i = 1 To 9
PaiXu i
Next
Text2.Text = ""
For i = 0 To 9
Text2.Text = Text2.Text & s(i) & ","
Next
End Sub
Private Sub Form_Load()
Dim i As Long
Text1 = ""
Text2.Text = ""
Randomize
For i = 0 To 9
s(i) = Fix(Rnd() * 90 + 10)
Text1.Text = Text1.Text & s(i) & ","
Next
End Sub
Public Sub MaxS(a As Long, b As Long)
Dim c As Long
If b < a Then
c = a
a = b
b = c
End If
End Sub
Public Sub PaiXu(n As Long)
Dim i As Long
DoEvents
If n < 0 Or n > 8 Then Exit Sub
MaxS s(n), s(n + 1)
PaiXu n - 1
End Sub