Explorer in Visual Basic 
Author Message
 Explorer in Visual Basic

Hi
I have a doubt with this procedure. I have a treeview and i want to show
folders and files like the Windows explorer. To do this, I define next
recursive procedure:

Public Function F_CalculaArbol(s_ruta As String, s_clavepadre As String) As
Boolean
Dim clave As String
Dim d1 As String

d1 = Dir(s_ruta, vbDirectory)
Do While d1 <> ""
    If d1 <> "." And d1 <> ".." Then
        If (GetAttr(s_ruta & d1) And vbDirectory) = vbDirectory Then     'Is
a Folder
            clave = "C" & l_contador
            Set nodX = Form1.arbol.Nodes.Add(s_clavepadre, tvwChild,
clave,d1)
            l_contador = l_contador + 1
            x = F_CalculaArbol(s_ruta & d1 & "\", clave)

        Else        'Is a file
            clave = "A" & l_contador
            Set nodX = Form1.arbol.Nodes.Add(s_clavepadre, tvwChild,
clave,d1)
            l_contador = l_contador + 1

        End If

    End If
    d1 = Dir

Loop

F_CalculaArbol = True

End Function

This function returns next error :
Call to a procedure or arguments no valids

Can you help me?
Thanks anyway.



Sun, 11 Dec 2005 15:38:12 GMT  
 Explorer in Visual Basic



Quote:
> Hi
> I have a doubt with this procedure. I have a treeview and i want to show
> folders and files like the Windows explorer. To do this, I define next
> recursive procedure:

> Public Function F_CalculaArbol(s_ruta As String, s_clavepadre As String)
As
> Boolean
> Dim clave As String
> Dim d1 As String

> d1 = Dir(s_ruta, vbDirectory)
> Do While d1 <> ""
>     If d1 <> "." And d1 <> ".." Then
>         If (GetAttr(s_ruta & d1) And vbDirectory) = vbDirectory Then
'Is
> a Folder
>             clave = "C" & l_contador
>             Set nodX = Form1.arbol.Nodes.Add(s_clavepadre, tvwChild,
> clave,d1)
>             l_contador = l_contador + 1
>             x = F_CalculaArbol(s_ruta & d1 & "\", clave)

>         Else        'Is a file
>             clave = "A" & l_contador
>             Set nodX = Form1.arbol.Nodes.Add(s_clavepadre, tvwChild,
> clave,d1)
>             l_contador = l_contador + 1

>         End If

>     End If
>     d1 = Dir

> Loop

> F_CalculaArbol = True

> End Function

> This function returns next error :
> Call to a procedure or arguments no valids

The problem is in the <d1 = Dir > statement.

This statement IS NOT recursive, thus, when you return
from the first recursion (a lower level), VB cannot continue
to generate the next file of the upper level.

A way to solve this problem is to insert all first-level
nodes, then, for each node of first level, insert all
the second-level nodes, and so on.

--
Er Roscio.



Sun, 11 Dec 2005 19:03:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Events from Internet Explorer in Visual Basic/VB.Net Applications

2. Starting Internet Explorer through Visual Basic Question

3. launch internet explorer in visual basic

4. brings up a new internet explorer in visual basic

5. Passing parameters to internet Explorer from Visual Basic

6. Recording Windows Explorer Actions with Visual Basic for Applications

7. Visual Basic and Internet Explorer

8. Explorer Bar and Visual Basic

9. Creating an Explorer Bar in Visual Basic

10. Use MS Explorer Chinese TrueType fonts with Visual Basic

11. Creating an Explorer Shell Extension with Visual Basic

12. do Visual Basic 6.0 and Visual Basic .NET version beta Working Both

 

 
Powered by phpBB® Forum Software