home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch11 / filescan / filescan.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-05-21  |  3.9 KB  |  136 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "FileScan"
  5.    ClientHeight    =   3540
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   7350
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3540
  13.    ScaleWidth      =   7350
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Scan Now"
  17.       BeginProperty Font 
  18.          Name            =   "Verdana"
  19.          Size            =   9.75
  20.          Charset         =   0
  21.          Weight          =   400
  22.          Underline       =   0   'False
  23.          Italic          =   0   'False
  24.          Strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   495
  27.       Left            =   5655
  28.       TabIndex        =   3
  29.       Top             =   2895
  30.       Width           =   1575
  31.    End
  32.    Begin VB.FileListBox File1 
  33.       BeginProperty Font 
  34.          Name            =   "Verdana"
  35.          Size            =   9
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   3240
  43.       Left            =   2775
  44.       TabIndex        =   2
  45.       Top             =   150
  46.       Width           =   2715
  47.    End
  48.    Begin VB.DirListBox Dir1 
  49.       BeginProperty Font 
  50.          Name            =   "Verdana"
  51.          Size            =   9
  52.          Charset         =   0
  53.          Weight          =   400
  54.          Underline       =   0   'False
  55.          Italic          =   0   'False
  56.          Strikethrough   =   0   'False
  57.       EndProperty
  58.       Height          =   2730
  59.       Left            =   120
  60.       TabIndex        =   1
  61.       Top             =   660
  62.       Width           =   2520
  63.    End
  64.    Begin VB.DriveListBox Drive1 
  65.       BeginProperty Font 
  66.          Name            =   "Verdana"
  67.          Size            =   9
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       Height          =   330
  75.       Left            =   105
  76.       TabIndex        =   0
  77.       Top             =   150
  78.       Width           =   2520
  79.    End
  80. Attribute VB_Name = "Form1"
  81. Attribute VB_GlobalNameSpace = False
  82. Attribute VB_Creatable = False
  83. Attribute VB_PredeclaredId = True
  84. Attribute VB_Exposed = False
  85. '  ******************************
  86. '  ******************************
  87. '  ** MASTERING VB6            **
  88. '  ** by Evangelos Petroutos   **
  89. '  ** SYBEX, 1998              **
  90. '  ******************************
  91. '  ******************************
  92. Dim InitialFolder
  93. Dim totalFiles As Integer
  94. Private Sub Command1_Click()
  95.     ChDrive Drive1.Drive
  96.     ChDir Dir1.Path
  97.     InitialFolder = CurDir
  98.     ScanFolders
  99.     MsgBox "There are " & totalFiles & " under the " & InitialFolder & " folder"
  100. End Sub
  101. Sub ScanFolders()
  102. Dim subFolders As Integer
  103.     totalFiles = totalFiles + File1.ListCount
  104.     subFolders = Dir1.ListCount
  105.     If subFolders > 0 Then
  106.         For i = 0 To subFolders - 1
  107.             ChDir Dir1.List(i)
  108.             Dir1.Path = Dir1.List(i)
  109.             File1.Path = Dir1.List(i)
  110.             Form1.Refresh
  111.             ScanFolders
  112.         Next
  113.     End If
  114.     File1.Path = Dir1.Path
  115.     MoveUp
  116. End Sub
  117. Sub MoveUp()
  118.     If Dir1.List(-1) <> InitialFolder Then
  119.         ChDir Dir1.List(-2)
  120.         Dir1.Path = Dir1.List(-2)
  121.     End If
  122. End Sub
  123. Private Sub Dir1_Change()
  124.     ChDir Dir1.Path
  125.     File1.Path = Dir1.Path
  126. End Sub
  127. Private Sub Drive1_Change()
  128.     ChDrive Dir1.Path
  129.     Dir1.Path = Drive1.Drive
  130.     Dir1.Refresh
  131. End Sub
  132. Private Sub Form_Load()
  133.     ChDrive App.Path
  134.     ChDir App.Path
  135. End Sub
  136.