获取路径名的原始大小写状态

标签: stringintegercommandfunctionjoinobject
949人阅读 评论(0) 收藏 举报
分类:

方法1:

'利用dir()循环:

------------------------------------

Option Explicit

Private Sub Command1_Click()
Dim s As String
s = "c:/program files/microsoft office/office11/winword.exe"
MsgBox "lcase: " & s & vbCrLf & "inipath: " & inipath(s)
End Sub
Function inipath(ByVal lcasepath As String) As String
Dim x() As String, temp() As String, n As Integer, i As Integer
x = Split(lcasepath, "/")
n = UBound(x)
ReDim temp(n)
temp(0) = UCase(x(0))
For i = n To 1 Step -1
ReDim Preserve x(i)
temp(i) = Join(x, "/")
temp(i) = IIf(i = n, Dir(temp(i)), Dir(temp(i), vbDirectory))
Next
inipath = Join(temp, "/")
End Function

 

方法2:

''使用File System Object:

Private Sub Command1_Click()
Dim s As String
s = "c:/program files/microsoft office/office11/winword.exe"
Dim fso As New FileSystemObject
MsgBox fso.GetAbsolutePathName(s)
End Sub

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:630862次
    • 积分:8212
    • 等级:
    • 排名:第2407名
    • 原创:205篇
    • 转载:26篇
    • 译文:1篇
    • 评论:213条
    最新评论