我使用的方法为: Dim iLen As Integer Dim i As Integer iLen = Len(App.path) For i = iLen To 1 Step -1 If Mid(App.path, i, 1) = "\" Then Outpath = Left(App.path, i) Exit For End If Next i总感觉很麻烦,VB没有系统函数来操作吗?
经过楼上的提醒,改成 Dim iLen As Integer Dim i As Integer iLen = Len(App.path) i = InStrRev(App.path, "\") Outpath = Left(App.path, i)谢谢了。
用 instrrev() 检测 \ 的位置再截取就可以了。
也就是几行代码。
Dim iLen As Integer
Dim i As Integer
iLen = Len(App.path)
For i = iLen To 1 Step -1
If Mid(App.path, i, 1) = "\" Then
Outpath = Left(App.path, i)
Exit For
End If
Next i总感觉很麻烦,VB没有系统函数来操作吗?
Dim iLen As Integer
Dim i As Integer
iLen = Len(App.path)
i = InStrRev(App.path, "\")
Outpath = Left(App.path, i)谢谢了。
Fol.ParentFolder
我个人不建议 fso,毕竟为了这么一个小功能而调用一个大对象,所消耗的资源是不合算的。