Public Function myChDir(sPath As String) As Boolean
来源:百度知道 编辑:UC知道 时间:2024/05/06 00:02:52
Public Function myChDir(sPath As String) As Boolean
On Error GoTo err1
If sPath = "" Then
myChDir = False
Exit Function
End If
If (Mid(sPath, 2, 1) = ":") Then
ChDrive (Mid(sPath, 1, 1)) 'ChDir won't work if curent path is another drive.
End If
ChDir (sPath)
myChDir = True
Exit Function
err1:
Debug.Print "Error (expected?) on myChDir(" & sPath & "): " & Err.Description
myChDir = False
Resume Next
End Function
这是什么意思?它是干什么用的?
On Error GoTo err1
If sPath = "" Then
myChDir = False
Exit Function
End If
If (Mid(sPath, 2, 1) = ":") Then
ChDrive (Mid(sPath, 1, 1)) 'ChDir won't work if curent path is another drive.
End If
ChDir (sPath)
myChDir = True
Exit Function
err1:
Debug.Print "Error (expected?) on myChDir(" & sPath & "): " & Err.Description
myChDir = False
Resume Next
End Function
这是什么意思?它是干什么用的?
这个是用来更改当前目录用的
参数sPath 是要改到的目录
On Error GoTo err1
这句表示如果出错就到
err1:
Debug.Print "Error (expected?) on myChDir(" & sPath & "): " & Err.Description
myChDir = False
Resume Next