|
不好意思,代码运行有错误,所以改了下
Public Function getwjname(ByVal FullPath As String) As String
Dim wz1 As Integer: wz1 = InStrRev(FullPath, "\") ' 获取“\”的最后位置
Dim wz2 As Integer: wz2 = InStrRev(FullPath, ".") ' 获取“.”的最后位置
'If myNo = 1 Then ' 第二参数为1
' NameAndPath = Mid(FullPath, Str2, Len(FullPath) - Str2 + 1) ' 返回: 尾缀名
'ElseIf myNo = 2 Then ' 第二参数为2
getwjname = Mid(FullPath, wz1 + 1, wz2 - wz1 - 1) ' 返回: 文件名
'ElseIf myNo = 3 Then ' 第二参数为3
' NameAndPath = Mid(FullPath, Str1 + 1, Len(FullPath) - Str1) ' 返回: 带后缀文件名
'ElseIf myNo = 4 Then ' 第二参数为4
' NameAndPath = Mid(FullPath, 1, Str1) ' 返回: 路径
'Else:
' NameAndPath = "" ' 其它,返回空值
'End If
End Function |
|