VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 从字符串中分离文件路径,文件名及其扩展名
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:12261, 日期:2001-06-20
从字符串中分离文件路径,文件名及其扩展名

--------------------------------------------------------------------------------
此函数从字符串中分离出路径
Function ParsePath (sPathIn As String) As String
 Dim I As Integer
 For I = Len(sPathIn) To 1 Step -1
  If InStr(":\", Mid$(sPathIn, I, 1)) Then Exit For
 Next
 ParsePath = Left$(sPathIn, I)
End Function
此函数从字符串中分离出文件名
Function ParseFileName (sFileIn As String) As String
 Dim I As Integer
 For I = Len(sFileIn) To 1 Step -1
  If InStr("\", Mid$(sFileIn, I, 1)) Then Exit For
 Next
 ParseFileName = Mid$(sFileIn, I + 1, Len(sFileIn) - I)
End Function
此函数从字符串中分离出文件扩展名
Function GetFileExt (sFileName As String) As String
 Dim P As Integer
 For P = Len(sFileName) To 1 Step -1
  If InStr(".", Mid$(sFileName, P, 1)) Then Exit For
 Next
 GetFileExt = Right$(sFileName, Len(sFileName) - P)
End Function