【急】 VB listbox控件怎样按日期排序。。
==。愁死了。这个是按数字大小和字母顺序的倒叙排序的。回答的可以借鉴一下我想按日期排序。按钮是Command3实在不行+Q931419783PrivateSubComma...
= =。愁死了。 这个是按数字大小和字母顺序的倒叙排序的。回答的可以借鉴一下 我想按日期排序。按钮是Command3 实在不行+Q 931419783
Private Sub Command3_Click()
For I = 1 To List1.ListCount - 1
For j = 0 To I - 1
If Bjzfc(List1.List(j), List1.List(I)) Then
k = List1.List(I)
List1.List(I) = List1.List(j)
List1.List(j) = k
End If
Next j
Next I
End Sub
Private Function Bjzfc(S1 As String, S2 As String) As Boolean
Dim I As Integer, T1 As Long, T2 As Long
For I = 1 To Len(S1)
If Val(Mid(S1, I, 1)) > 0 Then T1 = Val(Mid(S1, I)): Exit For
Next I
For I = 1 To Len(S1)
If Val(Mid(S2, I, 1)) > 0 Then T2 = Val(Mid(S2, I)): Exit For
Next I
If T1 > T2 Then Bjzfc = False Else Bjzfc = True
End Function 展开
Private Sub Command3_Click()
For I = 1 To List1.ListCount - 1
For j = 0 To I - 1
If Bjzfc(List1.List(j), List1.List(I)) Then
k = List1.List(I)
List1.List(I) = List1.List(j)
List1.List(j) = k
End If
Next j
Next I
End Sub
Private Function Bjzfc(S1 As String, S2 As String) As Boolean
Dim I As Integer, T1 As Long, T2 As Long
For I = 1 To Len(S1)
If Val(Mid(S1, I, 1)) > 0 Then T1 = Val(Mid(S1, I)): Exit For
Next I
For I = 1 To Len(S1)
If Val(Mid(S2, I, 1)) > 0 Then T2 = Val(Mid(S2, I)): Exit For
Next I
If T1 > T2 Then Bjzfc = False Else Bjzfc = True
End Function 展开
2013-11-22
展开全部
改造一下Bjzfc函数private function Bjzfc(byref s1 as string, byref s2 as string) as boolean Bjzfc = iif(DateValue(s1)>DateValue(s2), False, True)end function 没有测试,要确保传入的s1,s2为日期格式DateValue是内置的VBA类的DateTime模块带的函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询