VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   735
      Left            =   1920
      TabIndex        =   0
      Top             =   2520
      Width           =   1695
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Private Sub Command1_Click()
     Dim iA(1 To 10)
     n = 6
     iA(1) = 8: iA(2) = 6: iA(3) = 9: iA(4) = 3: iA(5) = 2: iA(6) = 7
     For i = 1 To n - 1              ' 进行n-1遍比较
        iMin = i                ' 对第i遍比较时，初始假定第i个元素最小
        For j = i + 1 To n              ' 在数组 i~n个元素中选最小元素的下标
            If iA(j) < iA(iMin) Then iMin = j
        Next j
        t = iA(i)                   'i~n个元素中选出的最小元素与第i个元素交换
        iA(i) = iA(iMin)
        iA(iMin) = t
       For k = 1 To n
        Print iA(k);
       Next k
       Print
    Next i

End Sub
