我的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
给我一个文件夹中的文件。好的。但是第二个电话给我Run-Time Error '5': Invalid Procedure Call or Argument
我对Dir
功能缺少什么?显然,这就是必须使用的方式。
当我处于调试模式时,在行Do While fileName > "" And Not trouve
,我在dir上的手表返回下一个文件。执行此行后,我的手表显示错误。
里面还有其他手表Dir(otherPath)
...我已将它们删除,现在可以正常工作了
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句