排序:
With ListView1
.Sorted = False
For i = 1 To .ListItems.Count
.ListItems(i).Text = Format(.ListItems(i).Text, "000000000000")
.ListItems(i).SubItems(1)=这里内容为文件容量大小 以kb md gb显示 例 行1为20.5kb 行2为17.6mb 请问这行代码如何写?
Next
.SortKey = Column.Index - 1
If .SortOrder = lvwAscending Then
.SortOrder = lvwDescending
ElseIf .SortOrder = lvwDescending Then
.SortOrder = lvwAscending
End If
.Sorted = True
For i = 1 To .ListItems.Count
.ListItems(i).Text = Val(.ListItems(i).Text)
.ListItems(i).SubItems(1)=这里内容为文件容量大小 以kb md gb显示 例 行1为20.5kb 行2为17.6mb 请问这行代码如何写?
Next
End With模块:Public Function FormatFileSize(ByVal Size As Long) As String
Dim sRet As String
Const KB& = 1024
Const MB& = KB * KB
If Size < KB Then
sRet = Format(Size, "#,##0") & " bytes"
Else
Select Case Size \ KB
Case Is < 10
sRet = Format(Size / KB, "0.00") & "KB"
Case Is < 100
sRet = Format(Size / KB, "0.0") & "KB"
Case Is < 1000
sRet = Format(Size / KB, "0") & "KB"
Case Is < 10000
sRet = Format(Size / MB, "0.00") & "MB"
Case Is < 100000
sRet = Format(Size / MB, "0.0") & "MB"
Case Is < 1000000
sRet = Format(Size / MB, "0") & "MB"
Case Is < 10000000
sRet = Format(Size / MB / KB, "0.00") & "GB"
End Select
End If
FormatFileSize = sRet
End Function