排序:
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
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
解决方案 »
- 针孔打印纸出现中间断开打印问题
- 在VB中如何对Access数据库创建查询?
- vb中的dll,组件,以及标准dll函数调用(求教,讨论)
- VC中0x0012在VB6中怎么定义?
- 求教:我写了一个类模块,编译的时候出现一个这样的提示(运行时未加入的工程不可见,这是什么?怎么可以解决?
- 高手帮忙解决???????????
- 怎样实现模糊查询?
- 能不能在ActiveX DLL中使用ActiveX控件啊
- 并口打印问题解决,送分!请ByTheWay(到此一游) 进来拿分!
- vb中遍历当前已打开Excel工作簿名称
- 在VB中怎样结束Excel进程
- 运行时错误'1004':应用程序定义的或对象定义的错误
else
.ListItems(i).SubItems(1) = FormatFileSize(Val(.ListItems(i).SubItems(1)))
这个我自己写了啊 显示类型不匹配.ListItems(i).SubItems(1)=FormatFileSize(Val(.ListItems(i).Text))这个1列的内容成text内容了
SubItems(1) 的类型就是 String。