Results 1 to 10 of 10

Thread: Need help with Directories

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    85

    Question

    VB Code:
    1. Public Function FileFinder(WatchDir As String) As String
    2. 'this function will find the file, if it does not find the file
    3. 'that means that it is correct, they have never sent us this file
    4. 'before
    5. Dim FileFinding As String
    6. Dim count As Integer
    7. Dim counts As String
    8. Dim result As Long
    9. Dim string2 As String
    10. Dim CaptionValue As Integer
    11. Dim Preferences As String
    12. Dim FileToDelete As String
    13. Dim DeleteMe As Boolean
    14.  
    15. count = 0
    16.  
    17. FileFinding = Dir(WatchDir) 'Where to look for.
    18. Do Until FileFinding = ""
    19.  
    20.     count = count + 1
    21.     FileName = FileFinding
    22.  
    23.     If PreferencesDelimitor <> "" Then
    24.         string2 = PreferencesDelimitor
    25.         result = AmtInStr(FileName, string2)
    26.         Preferences = PreferencesFileFormat - 1
    27.         If result <> Preferences Then
    28.             CaptionValue = 2
    29.             StatusCaptionCase (CaptionValue)
    30.             MoveFileTemp (FileName)
    31.         End If
    32.     Else
    33.         MsgBox ("You MUST choose a Delimitor and File Format")
    34.         Combo1.SetFocus
    35.     End If
    36.    
    37.     FileFinding = Dir 'this is where error occurs
    38.    
    39.     If result = Preferences Then
    40.         MoveFiles (FileName)
    41.         FileToDelete = FileName
    42.         DeleteMe = True
    43.     End If
    44.    
    45.     If DeleteMe = True Then
    46.         DeleteFileName (FileToDelete)
    47.         DeleteMe = False
    48.     End If
    49. Loop
    50.  
    51. counts = CStr(count)
    52. FileFinder = counts
    53. End Function
    I have the above function. It works, almost, when the file it is searching for is found it does what it is supposed to do until it reaches the end of the directory list and then it comes back with this error: Run-Time error '5': Invalid procedure call or argument. If it does not find the file then everything works fine. It stops working on FileFinding = Dir.

    Any suggestions??
    Last edited by Hack; Apr 5th, 2006 at 06:20 AM. Reason: Added [vbcode][/vbcode] tags for more clarity.
    Using VB6 Still Pluging away

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width