我的 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/