home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch10 / filescan / filescan.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  3.6 KB  |  126 lines

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