这样修改后应该符合你的要求
程序代码:
Option Explicit Dim rs As New ADODB.Recordset '定义字段 Dim rs1 As New ADODB.Recordset '定义字段 Dim cnn As New ADODB.Connection '定义数据连接 Private Sub Form_Load() Dim strCnn$, SQL As String strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\WL.mdb;Jet OLEDB:Database Password=" cnn.Open strCnn '打开连接 rs.Open "select * from WL ", cnn, adOpenDynamic, adLockBatchOptimistic End Sub Private Sub Command1_Click() Dim a As String Dim arr(1 To 9) As Integer Dim arr1(1 To 9) As Integer Dim arrstr(1 To 9) As String Dim arrstr1(1 To 9) As String Dim I, j, T, p, q As Integer For I = 1 To 9 a = rs.Fields(I + 1) arr(I) = Val(a) q = I arr1(q) = Val(a) arrstr(q) = rs.Fields(q + 1).Name Next I For q = 1 To 9 Print "+++++++++++++++"; arr1(q) & "==========>" & arrstr(q) Next q For I = 1 To 8 For j = I + 1 To 9 ' If arr(j) > arr(j + 1) Then If arr(I) > arr(j) Then T = arr(I): arr(I) = arr(j): arr(j) = T T = arrstr(I): arrstr(I) = arrstr(j): arrstr(j) = T End If Next j Next I For p = 9 To 1 Step -1 Print arr(p) & "==========>" & arrstr(p) ' & rs.Fields(i + 1).Name Combo1.AddItem arrstr(p) List1.AddItem arrstr(p) Label1(9 - p) = arr(p) Text1(9 - p) = arrstr(p) Next p End Sub
能编个毛线衣吗?