Results 1 to 4 of 4

Thread: type mismatch in findnextfile

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Unhappy

    Can some one help me out on this one. I get a type mismatch and I can't figure out why it is in a directory where it won't get caught up on folders. the error break down where I have it marked.

    Dim file As Win32_Find_data
    Dim search As Long
    Dim success As Long
    Dim buffer As Long
    search = FindFirstFile("C:\Windows*.*", file)
    If search = -1 Then
    Debug.Print "No files found"
    End
    End If
    Do
    'error breaks here' buffer = Left(file.cFileName, InStr(file.cFileName, vbNullChar) - 1)
    Debug.Print buffer

    success = FindNextFile(search, file)
    Loop Until success = 0

    End Sub
    Matt

  2. #2
    Junior Member
    Join Date
    Mar 1999
    Posts
    27
    You declared buffer as a long. Buffer needs to be a string (or variant). I recommend string and instead of Left() (which, I believe returns a variant) use Left$().

    Good Luck!

  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Unhappy

    Thanks, but I still get a return value of €»RÞð¿
    ÀÈUÞð¿. What the ????.
    Matt

  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    It seems that you have a problem with InStr Function. You have
    Code:
    'error breaks here'
    buffer = Left(1,file.cFileName, InStr(file.cFileName, vbNullChar) - 1)
    The correct syntax should be:
    Code:
    buffer = Left(1,file.cFileName, InStr(1, file.cFileName, vbNullChar) - 1)
    HTH

    Post #500

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