vb6 - VB6 中的 Dir 函数 - 错误 5

标签 vb6 dir

我的 Dir 函数有问题。

Private Sub InitFileElvt()
    Dim fileName As String
    Dim find As Boolean
    Dim trouve As Boolean
    trouve = False
    fileName = Dir(THEORIQUE & "\" & LibPie & CftMot & _ 
               Mid(NoPlan, 13, 1) & Mid(VERPIE, 1, 1) & "\") 'It works here
    Do While fileName > "" And Not trouve
        If IsElvtFile(fileName) Then
            trouve = True
            pathFileElvt = THEORIQUE & "\" & fileName
        End If
        fileName = Dir() 'An error here
    Loop
    If Not trouve Then
        pathFileElvt = "empty"
    End If
End Sub

Private Function IsElvtFile(ByVal fileName As String) As Boolean 
    Dim lengthDeb As Integer
    lengthDeb = Len(LibPie) + Len(CftMot) + 1
    IsElvtFile = Left(fileName, lengthDeb) = LibPie + CftMot + Mid(NoPlan, 13, 1) And _
                 Right(fileName, 4) = ".ELV"
End Function

第一次调用 Dir 会从该文件夹中获取一个文件。好的。但第二次调用给我运行时错误'5':无效的过程调用或参数

我对 Dir 函数缺少什么?显然,这就是它的使用方式。

当我处于 Debug模式时,在 Do While fileName > ""And Not trouve 行中,我的 watch 在 dir 上返回下一个文件。执行此行后,我的 watch 显示错误。

最佳答案

Dir(otherPath) 中有其他 watch ... 我已经删除了它们,现在它可以工作了

关于vb6 - VB6 中的 Dir 函数 - 错误 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30660196/

相关文章:

windows批处理dir命令获取以字符串开头的最后修改目录

linux - 关于 ls、dir 和 tee 的混淆

visual-studio - 从 Visual Basic 6 中的所有对象上移除焦点

visual-c++ - 我如何知道我的程序是否需要 MDAC?

c++ - 如何从 VB6 调用 C++ 类库

python - 如何使用循环获取dir()中的值?

vb6 - 如何在vb6.0中显示缩小的网页浏览器

vb6 - 如何查看文件大小?

python获取调用函数的当前变量

node.js 文件上传错误 : ENOENT, 重命名 ' tmp/xxxxxx.jpeg' ,认为错误在我的路径中,我做错了什么?