Public Class 例5_12

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a() As Single, t As Single
        Dim n As Integer, i As Integer, j As Integer
        n = InputBox("请输入数据的个数")
        ReDim a(n - 1)                        '根据n动态改变数组大小
        For i = 0 To n - 1
            a(i) = InputBox("请输入第" + Str(i + 1) + "个数")
            TextBox1.Text = TextBox1.Text & a(i) & vbTab
        Next i
        For i = 0 To n - 2
            For j = i + 1 To n - 1
                If a(i) > a(j) Then
                    t = a(i) : a(i) = a(j) : a(j) = t
                End If
            Next
        Next
        For i = 0 To n - 1
            TextBox2.Text = TextBox2.Text & a(i) & vbTab
        Next i

    End Sub
End Class