Results 1 to 3 of 3

Thread: GetFolder type mismatch

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Post

    Hello VB gurus. Hope you are well.

    Spot the deliberate mistake...

    Code:
    Private Sub ShowFolders(ByVal DirName As String)
    
    Dim fso As New FileSystemObject, fld As Folder, flds As Folders
    Dim fo As Folder
    
    Set fo = fso.GetFolder(DirName)
    Set flds = fo.SubFolders
    
    For Each fld In flds
         tvTreeView.Nodes.Add DirName, tvwChild, fld.Name, fld.Name
    Next
    
    Set fo = Nothing
    Set flds = Nothing
    
    End Sub
    Whenever I run this, I get "Runtime error '13' - Type Mismatch" at "Set fo = fso.GetFolder(DirName)". DirName is (example) "E:\". This is an EXACT word-for-word copy from another application that works, just this one doesn't. Can anyone tell me why? I'm going rapidly mad.

    Thank you very much
    T
    Some cause happiness wherever they go; others, whenever they go.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Using your code and passing the DirName, it worked just fine. Here is how I used it:


    ShowFolders "C:\"


    The only error I've got was a TreeView error, since I didn't
    have any parents in the TreeView, so this line:
    tvTreeView.Nodes.Add DirName, tvwChild, fld.Name, fld.Name
    was failing because I didn't have any parent node to add a child to. But that's another issue.

    Edited by Serge on 03-15-2000 at 11:03 AM

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Posts
    81

    Post

    Ah well. Thanks anyway Serge.

    T
    Some cause happiness wherever they go; others, whenever they go.

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