如果不是,则判断是否可以按此字符串创建新目录或该字符串不能作为合法的目录名使用?

解决方案 »

  1.   

    IIf(Dir(Str1, vbDirectory) <> "", True, False)
      

  2.   

    '模 块 名:IsPath
    '功    能:判断有没有这个路径
    '返 回 值:成功/失败:True/False
    '参    数:IsPath(要判断的路径)
    '引    用:无
    '外部函数:无
    '内部变量:无
    '调用方法:MsgBox IsPath("C:\Windows")
    Public Function IsPath(ByVal Path As String) As Boolean
        On Error GoTo 1
        IsPath = False
        MkDir Path
        RmDir Path
        Exit Function
    1:
        IsPath = True
    End Function
      

  3.   

    IIf(Dir(Str1, vbDirectory) <> "", True, False)
      

  4.   

    判断 dir(YourPath,vbDirectory)<>""
      

  5.   

    除了楼上的用法还有用fso的方式
    引用microsoft script runtimedim ObjFS As New Scripting.FileSystemObject
    If ObjFS.FolderExists(你的字符串) = False Then
        MsgBox "不存在该文件夹!", vbInformation, Me.Caption
        Exit Sub
    End If