看上去似乎是一个数据表的各字段名. 排序应使用SQL语句: SQL = "SELECT 学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员 FROM 数据表名 ORDER by 姓名" 这是按姓名排序
词组排序代码: Option Explicit Dim strsj() As String Dim strTemp As String Dim sj As String Dim i As Integer Dim j As IntegerPrivate Sub Command1_Click() sj = "学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员" strsj = Split(sj, ",") For i = 1 To UBound(strsj) For j = i To UBound(strsj) If strsj(i) > strsj(j) Then strTemp = strsj(i) strsj(i) = strsj(j) strsj(j) = strTemp End If Next 'Print strsj(i) & " " & i Next For i = 0 To UBound(strsj) Print strsj(i) Next End Sub
代码有误,修改如下:Option Explicit Dim strsj() As String Dim strTemp As String Dim sj As String Dim i As Integer Dim j As IntegerPrivate Sub Command1_Click() sj = "学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员" strsj = Split(sj, ",") For i = 0 To UBound(strsj) For j = i To UBound(strsj) If strsj(i) > strsj(j) Then strTemp = strsj(i) strsj(i) = strsj(j) strsj(j) = strTemp End If Next Next Print For i = 0 To UBound(strsj) Print strsj(i) & " "; Next End Sub
排序应使用SQL语句:
SQL = "SELECT 学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员 FROM 数据表名 ORDER by 姓名"
这是按姓名排序
Option Explicit
Dim strsj() As String
Dim strTemp As String
Dim sj As String
Dim i As Integer
Dim j As IntegerPrivate Sub Command1_Click()
sj = "学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员"
strsj = Split(sj, ",")
For i = 1 To UBound(strsj)
For j = i To UBound(strsj)
If strsj(i) > strsj(j) Then
strTemp = strsj(i)
strsj(i) = strsj(j)
strsj(j) = strTemp
End If
Next
'Print strsj(i) & " " & i
Next
For i = 0 To UBound(strsj)
Print strsj(i)
Next
End Sub
Dim strsj() As String
Dim strTemp As String
Dim sj As String
Dim i As Integer
Dim j As IntegerPrivate Sub Command1_Click()
sj = "学校,班级,姓名,学号,性别,出生年月,家庭住址,是否团员"
strsj = Split(sj, ",")
For i = 0 To UBound(strsj)
For j = i To UBound(strsj)
If strsj(i) > strsj(j) Then
strTemp = strsj(i)
strsj(i) = strsj(j)
strsj(j) = strTemp
End If
Next
Next
Print
For i = 0 To UBound(strsj)
Print strsj(i) & " ";
Next
End Sub
因为vb这个bt的东东
shell排序大部分的情况下都比快速排序要快也可以引用dao对象创建临时表进行排序,这个灵活性比较好,效率也可以