Public Function GetFilesize(ByVal strFilePath As String) As Long On Error GoTo ErrHandle: Dim fso as Object,myFile as Object Set fso = CreateObject("Scripting.FileSystemObject") Set myFile = fso.GetFile(strFilePath) GetFilesize = myFile.Size Exit Function ErrHandle: GetFilesize = 0 End Function
Dim lngLenOfFile as long Open "filename" for Input as #1 lngLenOfFile = LOF(1) Close #1
len()函数 比如:msgbox len(text1.text)
FSO,全稱是File System Object。 在MSDN中搜索一下吧。
这么简单的问题,竟然还要用api,fso?
function getfilelength(filepath as string) as long if filepath<>"" then open filepath for binary as #1 getfilelength=lof(1) close(1) end if end function
On Error GoTo ErrHandle:
Dim fso as Object,myFile as Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set myFile = fso.GetFile(strFilePath)
GetFilesize = myFile.Size
Exit Function
ErrHandle:
GetFilesize = 0
End Function
Open "filename" for Input as #1
lngLenOfFile = LOF(1)
Close #1
比如:msgbox len(text1.text)
在MSDN中搜索一下吧。
if filepath<>"" then
open filepath for binary as #1
getfilelength=lof(1)
close(1)
end if
end function
有可以看文件大小等的功能
而且功能很多的啊