Avviare Microsoft Visual Basic Express , fare clic su " Nuovo progetto ... " nel riquadro sinistro dello schermo , quindi selezionare " Applicazione Windows Form ". Fare clic su "OK". 
 
 2 Fare doppio clic su " TreeView " nel riquadro " Casella degli strumenti " per aggiungere un nuovo controllo TreeView . Fare doppio clic su " Form1 " per aprire il modulo " Form1.vb " . 
 3 
 Digitare il seguente sotto " Form1 Load " per definire il percorso di origine per iniziare la ricerca e per aggiungere il primo nodo : 
 
Dim frstNode As New System.Windows.Forms.TreeNode ( ) per
 frstNode.ImageIndex = 0 
 
 frstNode.SelectedImageIndex = 0 
 
 frstNode . text = " G : \\ " 
 
TreeView1.Nodes.Add ( frstNode ) economici 4
 Click " Form1.vb [Design] " e fare doppio clic sul controllo " TreeView " . Digitare quanto segue per aggiungere directory e file al controllo : 
 
 Dim obj As New Process 
 
 Text = e.Node.Text 
 
 Directory.Exists ( e.Node . Text ) = True Then 
 
getfiles ( e.Node , e.Node.Text ) per
 End If 
 
 File.Exists ( e.Node.Text ) = true Then 
 
obj.Start ( e.Node.Text , AppWinStyle.MaximizedFocus ) per
 End If 
 5 
 Digitare il seguente sotto " Public Class Form1 " al creare una nuova subroutine che cercherà directory e file : 
 
getfiles private Sub ( ByVal pNode Come TreeNode , ByVal dirStr As String ) per
 Dim myDir quanto Elenco 
 
 Dim iCnt As Integer 
 
 iCnt = 0 A ( myDir.GetDirectories ( dirStr ) Lunghezza . ) - 1 
 
 Dim childNode come nuovo _ 
 
TreeNode ( myDir.GetDirectories ( dirStr ) ( iCnt ) . ToString , 1 , 0 ) per
iCnt = pNode.Nodes.Add ( childNode ) per
 Successivo iCnt 
 
 iCnt = 0 A ( myDir.GetFiles ( dirStr " . * xls ") Lunghezza ) - . 1 
 
 Dim childNode As New _ 
 
TreeNode ( myDir.GetFiles ( dirStr , " * . xls " ) ( iCnt ) ToString . 2 , 2 ) per
iCnt = pNode.Nodes.Add ( childNode ) per
 Successivo iCnt 
 
pNode.Expand ( ) per
 End Sub 
 Pagina 6 
 Premere " F5 " per eseguire la subroutine quindi fare clic su un file Excel per aprirlo. 
 
              
Programmazione © www.354353.com