我通过程序已经获得了文件大小
set FileObj = Filesys.GetFile("文件名")
kk = FileObj.size
问题:
如何使用select Case 编写
kk/1024/1024>0 --- dubug.print cstr(rount(kk)) & "MB"
kk/1024>0 --- dubug.print cstr(rount(kk)) & "KB"
kk>0 --- dubug.print cstr(rount(kk)) & "B"
我用的方法是
select case kk
case kk/1024/1024>0
dubug.print cstr(rount(kk)) & "MB"
case kk/1024>0
dubug.print cstr(rount(kk)) & "kB"
case kk>0
dubug.print cstr(rount(kk)) & "B"
end select
运行不通过
请教各位大侠,如何解决,谢谢.
set FileObj = Filesys.GetFile("文件名")
kk = FileObj.size
问题:
如何使用select Case 编写
kk/1024/1024>0 --- dubug.print cstr(rount(kk)) & "MB"
kk/1024>0 --- dubug.print cstr(rount(kk)) & "KB"
kk>0 --- dubug.print cstr(rount(kk)) & "B"
我用的方法是
select case kk
case kk/1024/1024>0
dubug.print cstr(rount(kk)) & "MB"
case kk/1024>0
dubug.print cstr(rount(kk)) & "kB"
case kk>0
dubug.print cstr(rount(kk)) & "B"
end select
运行不通过
请教各位大侠,如何解决,谢谢.
解决方案 »
- 建议帖:在发帖或回复中,加上显示IP地址的头2段或者3段
- 有能让VB做多线程下载的控件吗?
- 奇怪的vbKeyDivide问题...急...各位救命啊.??
- 判断信息是否被写进注册表???
- 网页上的ActiveX控件工作原理?
- 请问如何在InstallShield中执行DOS命令
- vb中记录集为空时,如何往数据库中添加数据?
- 谁可以提供 EXCLE 的常量?或VBAXL8.HLP 文件?谢谢了!!
- RegSetValue是什么意思?
- VBA(VB)如何实现PHP中函数hash_hmac(‘sha512’, $data, $key)的功能?
- 大家来讨论下这 SQL 语言要怎么写? 好象有点难度
- 能否实现2个窗口的程序下次启动后只运行一个?
Public Function ConvertBytes(Bytes As Double, Optional DecimalPlaces As Byte = 2, Optional ShowSuffix As Boolean = True) As String
Select Case Bytes
Case 0 To 1023 'Bytes
ConvertBytes = FormatNumber(Bytes, 0)
If ShowSuffix Then ConvertBytes = ConvertBytes & " bytes"
Case 1024 To 1048575 'KB
ConvertBytes = FormatNumber(Bytes / 1024, DecimalPlaces)
If ShowSuffix Then ConvertBytes = ConvertBytes & " KB"
Case 1048576 To 1073741823 'MB
ConvertBytes = FormatNumber(Bytes / 1048576, DecimalPlaces)
If ShowSuffix Then ConvertBytes = ConvertBytes & " MB"
Case Else 'GB
ConvertBytes = FormatNumber(Bytes / 1073741824, DecimalPlaces)
If ShowSuffix Then ConvertBytes = ConvertBytes & " GB"
End Select
End FunctionPrivate Sub Command11_Click() '字节值转换为单位
sByte = ConvertBytes(nByte, 2, True) '保留2位小数,显示单位
End Sub