问: 在vb中 让list中的数据按字母排序该怎么做(写在一个单击事件中)
1个回答
展开全部
排序前的项目显示情况
排序后的项目显示情况
Dim AA(1 To 8) As String '定义AA数组为模块级数组变量
Private Sub Command1_Click() '【排序】按钮单击过程
Dim KK As String
For I = 1 To 7 '数组的排序过程
For J = I + 1 To 8
If AA(I) > AA(J) Then
KK = AA(I)
AA(I) = AA(J)
AA(J) = KK
End If
Next J
Next I
List1.Clear '初始化List1控件
For I = 1 To 8
List1.AddItem AA(I) '加载排序后数组到List1
Next I
End Sub
Private Sub Command2_Click() '【刷新】按钮单击过程
Unload Me
Form1.Show
End Sub
Private Sub Form_Load() '程序启动过程
AA(1) = "TSPK": AA(2) = "UCXZ": AA(3) = "WKCV": AA(4) = "LMCS": AA(5) = "ZMNC": AA(6) = "CDGK": AA(7) = "ANME": AA(8) = "FCML" '给数组赋值
List1.Clear '初始化List1控件
For I = 1 To 8
List1.AddItem AA(I) '加载数组到List1
Next I
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询