用Dir得到文件名(包含扩展名)
再检测"."的位置,用Left函数取"."前的字符
Public Function gstrGetFileName(ByVal strTemp As String)
   Dim intTemp As Integer
   intTemp=Instr(strTemp,".")
   gstrGetFileName=Left(strTemp,intTemp-1)
End Function调用gstrGetFileName("D:\clc\clc\map\hb0101110.tab")

解决方案 »

  1.   

    用InStrRev函数求最后一个"\"的位置,截取它右边的字符串
      

  2.   

    只获得不包括扩展名的文件名Filename = Mid(path, InStrRev(path, "\", -1, vbTextCompare) + 1, InStrRev(path, ".", -1, vbTextCompare) - InStrRev(path, "\", -1, vbTextCompare) - 1)
      

  3.   

    Private Function GetFileName(str As String) As String
      Dim pos1 As Long, pos2 As Long
      
      pos1 = InStrRev(str, "\")
      pos2 = InStrRev(str, ".")
      GetFileName = Mid$(str, pos1 + 1, pos2 - pos1 - 1)
    End Function
      

  4.   

    Public Function Filename(ByVal sFilePathName As String) As StringDo While InStr(sFilePathName, "\") > 0
          sFilePathName = Right(sFilePathName, Len(sFilePathName) - InStr(sFilePathName, "\"))
          Filename = ""
          Filename = sFilePathName
     Loop
    End Function
    包你可以!