Private Function GetFileName(ByVal FullPath As String) As String
FullPath = Dir(FullPath)
GetFileName = Left(FullPath, InStr(FullPath, ".") - 1)
End Function
Private Sub Command1_Click()
MsgBox GetFileName("c:\01\01\northwind.mdf")
End Sub
Public Function GetFileName() as String
dim iPos as Integer
dim str as String,strTmp as string
str = "c:\01\01\northwind.mdf"
iPos=InstrRev(str,"\") '最后一个\的位置
if iPos<=0 then
msgbox "文件名错误"
exit function
end if
strTmp=Mid(str,iPos+1) '文件名包含扩展名
iPos=InstrRev(strTmp,".") '最后一个.的位置
if iPos>1 Then strTmp=Left(strTmp,iPos-1)
GetFileName=strTmp
End Function
Public Function GetFileName() as String
dim iPos as Integer
dim str as String,strTmp as string
str = "c:\01\01\northwind.mdf"
iPos=InstrRev(str,"\") '最后一个\的位置
if iPos<=0 then
msgbox "文件名错误"
exit function
end if
strTmp=Mid(str,iPos+1) '文件名包含扩展名
iPos=InstrRev(strTmp,".") '最后一个.的位置
if iPos>1 Then strTmp=Left(strTmp,iPos-1)
GetFileName=strTmp
End Function
function GetFileName(byval fullpath as string ) as string
dim x as long
x =instrrev(fullpath,"\")
if x then fullpath=mid(fullpath,x+1)
x=instrrev(fullpath,".")
if x>1 then fullpath=left(fullpath,x-1)
GetFileName=fullpath
end function
'未调试