vb用TEXT1的輸入內容命名為建立多級檔案夾的名字
uj5u.com熱心網友回復:
沒明白什么意思。建檔案夾是MKDIR
uj5u.com熱心網友回復:
大概的代碼,請參考:Option Explicit
Sub test()
Dim w1 As String
w1 = CreatePath("d:\fg\fg\fg")
If w1 <> "" Then MsgBox w1
End Sub
Function CreatePath(ByVal bPath As String) As String
CreatePath = "請輸入正確的路徑!" ''''給一個默認的錯誤資訊
bPath = Trim(bPath)
If Len(bPath) = 0 Then Exit Function
bPath = bPath & "\"
On Error GoTo errs
Dim s1 As String, i As Integer, s2 As String, pp
pp = Split(bPath, "\")
If UBound(pp) > 1 Then
s1 = pp(0)
For i = 1 To UBound(pp) - 1
s2 = Trim(pp(i))
If s2 = "" Then Exit Function
s1 = s1 & "\" & s2
If Dir$(s1, vbDirectory) = "" Then MkDir s1
Next
End If
CreatePath = ""
Exit Function
errs:
CreatePath = Err.Description
End Function
...
uj5u.com熱心網友回復:

你的另一個帖子,那個代碼應該是“正確”的。
你說“不行”,是不是你的輸入有什么錯誤?
還有就是有沒有權限在“目標檔案夾”內創建新的檔案夾?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/65424.html
標籤:VB基礎類
上一篇:combo里怎么放制表符?
