home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / findfi1a / find1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-12  |  33.3 KB  |  793 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
  4. Begin VB.Form Form1 
  5.    Caption         =   "Find:"
  6.    ClientHeight    =   6555
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   6360
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6555
  12.    ScaleWidth      =   6360
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin TabDlg.SSTab SSTab1 
  15.       Height          =   2130
  16.       Left            =   75
  17.       TabIndex        =   5
  18.       Top             =   90
  19.       Width           =   4485
  20.       _ExtentX        =   7911
  21.       _ExtentY        =   3757
  22.       _Version        =   393216
  23.       Tab             =   1
  24.       TabHeight       =   520
  25.       TabCaption(0)   =   "Name & Location"
  26.       TabPicture(0)   =   "FIND1.frx":0000
  27.       Tab(0).ControlEnabled=   0   'False
  28.       Tab(0).Control(0)=   "cmdBrowse"
  29.       Tab(0).Control(1)=   "chkMatchCase"
  30.       Tab(0).Control(2)=   "Command4"
  31.       Tab(0).Control(3)=   "txtExt"
  32.       Tab(0).Control(4)=   "txtText"
  33.       Tab(0).Control(5)=   "txtPath"
  34.       Tab(0).Control(6)=   "Label1"
  35.       Tab(0).Control(7)=   "Label2"
  36.       Tab(0).Control(8)=   "Label3"
  37.       Tab(0).ControlCount=   9
  38.       TabCaption(1)   =   "Date"
  39.       TabPicture(1)   =   "FIND1.frx":001C
  40.       Tab(1).ControlEnabled=   -1  'True
  41.       Tab(1).Control(0)=   "Label6"
  42.       Tab(1).Control(0).Enabled=   0   'False
  43.       Tab(1).Control(1)=   "Label5"
  44.       Tab(1).Control(1).Enabled=   0   'False
  45.       Tab(1).Control(2)=   "Label4"
  46.       Tab(1).Control(2).Enabled=   0   'False
  47.       Tab(1).Control(3)=   "txtTo"
  48.       Tab(1).Control(3).Enabled=   0   'False
  49.       Tab(1).Control(4)=   "txtFrom"
  50.       Tab(1).Control(4).Enabled=   0   'False
  51.       Tab(1).Control(5)=   "cboDate"
  52.       Tab(1).Control(5).Enabled=   0   'False
  53.       Tab(1).ControlCount=   6
  54.       TabCaption(2)   =   "Advanced"
  55.       TabPicture(2)   =   "FIND1.frx":0038
  56.       Tab(2).ControlEnabled=   0   'False
  57.       Tab(2).Control(0)=   "Combo1"
  58.       Tab(2).Control(1)=   "cboSize"
  59.       Tab(2).Control(2)=   "txtSize"
  60.       Tab(2).Control(3)=   "Label8"
  61.       Tab(2).Control(4)=   "Label7"
  62.       Tab(2).Control(5)=   "Label9"
  63.       Tab(2).ControlCount=   6
  64.       Begin VB.ComboBox Combo1 
  65.          Height          =   315
  66.          Left            =   -73980
  67.          TabIndex        =   26
  68.          Text            =   "Combo1"
  69.          Top             =   405
  70.          Width           =   2925
  71.       End
  72.       Begin VB.ComboBox cboSize 
  73.          Height          =   315
  74.          ItemData        =   "FIND1.frx":0054
  75.          Left            =   -73935
  76.          List            =   "FIND1.frx":005E
  77.          TabIndex        =   23
  78.          Top             =   900
  79.          Width           =   1560
  80.       End
  81.       Begin VB.CommandButton cmdBrowse 
  82.          Caption         =   "&Browse..."
  83.          Height          =   360
  84.          Left            =   -72165
  85.          TabIndex        =   22
  86.          Top             =   1650
  87.          Width           =   1245
  88.       End
  89.       Begin VB.CheckBox chkMatchCase 
  90.          Caption         =   "Match Case"
  91.          Height          =   195
  92.          Left            =   -74895
  93.          TabIndex        =   21
  94.          Top             =   1710
  95.          Width           =   1335
  96.       End
  97.       Begin VB.CommandButton Command4 
  98.          Caption         =   "&Browse"
  99.          Height          =   540
  100.          Left            =   -70020
  101.          TabIndex        =   20
  102.          Top             =   1350
  103.          Width           =   1260
  104.       End
  105.       Begin VB.TextBox txtSize 
  106.          Height          =   285
  107.          Left            =   -72225
  108.          TabIndex        =   19
  109.          Top             =   915
  110.          Width           =   915
  111.       End
  112.       Begin VB.ComboBox cboDate 
  113.          Height          =   315
  114.          ItemData        =   "FIND1.frx":0073
  115.          Left            =   915
  116.          List            =   "FIND1.frx":0080
  117.          TabIndex        =   11
  118.          Top             =   555
  119.          Width           =   3225
  120.       End
  121.       Begin VB.TextBox txtFrom 
  122.          Height          =   285
  123.          Left            =   930
  124.          TabIndex        =   10
  125.          Top             =   1035
  126.          Width           =   1155
  127.       End
  128.       Begin VB.TextBox txtTo 
  129.          Height          =   285
  130.          Left            =   2925
  131.          TabIndex        =   9
  132.          Top             =   1050
  133.          Width           =   1185
  134.       End
  135.       Begin VB.TextBox txtExt 
  136.          Height          =   315
  137.          Left            =   -73545
  138.          TabIndex        =   8
  139.          Top             =   510
  140.          Width           =   2895
  141.       End
  142.       Begin VB.TextBox txtText 
  143.          Height          =   315
  144.          Left            =   -73545
  145.          TabIndex        =   7
  146.          Top             =   885
  147.          Width           =   2895
  148.       End
  149.       Begin VB.TextBox txtPath 
  150.          Height          =   315
  151.          Left            =   -73545
  152.          TabIndex        =   6
  153.          Top             =   1275
  154.          Width           =   2895
  155.       End
  156.       Begin VB.Label Label8 
  157.          Caption         =   "Of type"
  158.          Height          =   240
  159.          Left            =   -74865
  160.          TabIndex        =   27
  161.          Top             =   465
  162.          Width           =   870
  163.       End
  164.       Begin VB.Label Label7 
  165.          Caption         =   "File Size Is"
  166.          Height          =   270
  167.          Left            =   -74865
  168.          TabIndex        =   24
  169.          Top             =   900
  170.          Width           =   810
  171.       End
  172.       Begin VB.Label Label9 
  173.          Caption         =   "KB"
  174.          Height          =   225
  175.          Left            =   -71280
  176.          TabIndex        =   18
  177.          Top             =   945
  178.          Width           =   285
  179.       End
  180.       Begin VB.Label Label4 
  181.          Caption         =   "Find all files"
  182.          Height          =   240
  183.          Left            =   60
  184.          TabIndex        =   17
  185.          Top             =   630
  186.          Width           =   915
  187.       End
  188.       Begin VB.Label Label5 
  189.          Caption         =   "From date"
  190.          Height          =   270
  191.          Left            =   60
  192.          TabIndex        =   16
  193.          Top             =   1095
  194.          Width           =   975
  195.       End
  196.       Begin VB.Label Label6 
  197.          Caption         =   "To date"
  198.          Height          =   255
  199.          Left            =   2235
  200.          TabIndex        =   15
  201.          Top             =   1065
  202.          Width           =   570
  203.       End
  204.       Begin VB.Label Label1 
  205.          Caption         =   "Named"
  206.          Height          =   225
  207.          Left            =   -74820
  208.          TabIndex        =   14
  209.          Top             =   540
  210.          Width           =   870
  211.       End
  212.       Begin VB.Label Label2 
  213.          Caption         =   "Look in"
  214.          Height          =   225
  215.          Left            =   -74805
  216.          TabIndex        =   13
  217.          Top             =   1350
  218.          Width           =   870
  219.       End
  220.       Begin VB.Label Label3 
  221.          Caption         =   "Containing Text"
  222.          Height          =   225
  223.          Left            =   -74835
  224.          TabIndex        =   12
  225.          Top             =   930
  226.          Width           =   1125
  227.       End
  228.    End
  229.    Begin VB.CommandButton cmdClear 
  230.       Caption         =   "New Search"
  231.       Height          =   390
  232.       Left            =   4950
  233.       TabIndex        =   4
  234.       Top             =   915
  235.       Width           =   1290
  236.    End
  237.    Begin ComctlLib.StatusBar StatusBar1 
  238.       Align           =   2  'Align Bottom
  239.       Height          =   285
  240.       Left            =   0
  241.       TabIndex        =   3
  242.       Top             =   6270
  243.       Width           =   6360
  244.       _ExtentX        =   11218
  245.       _ExtentY        =   503
  246.       SimpleText      =   ""
  247.       _Version        =   327682
  248.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  249.          NumPanels       =   1
  250.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  251.             Object.Width           =   4410
  252.             MinWidth        =   4410
  253.             Key             =   ""
  254.             Object.Tag             =   ""
  255.          EndProperty
  256.       EndProperty
  257.    End
  258.    Begin VB.CommandButton cmdUnload 
  259.       Caption         =   "&Close"
  260.       Height          =   375
  261.       Left            =   4935
  262.       TabIndex        =   2
  263.       Top             =   465
  264.       Width           =   1305
  265.    End
  266.    Begin ComctlLib.ListView ListView1 
  267.       Height          =   4050
  268.       Left            =   0
  269.       TabIndex        =   1
  270.       Top             =   2235
  271.       Width           =   6375
  272.       _ExtentX        =   11245
  273.       _ExtentY        =   7144
  274.       View            =   3
  275.       LabelWrap       =   -1  'True
  276.       HideSelection   =   -1  'True
  277.       _Version        =   327682
  278.       ForeColor       =   -2147483640
  279.       BackColor       =   -2147483643
  280.       BorderStyle     =   1
  281.       Appearance      =   1
  282.       NumItems        =   0
  283.    End
  284.    Begin VB.CommandButton cmdFind 
  285.       Caption         =   "&Find Now"
  286.       Default         =   -1  'True
  287.       Height          =   360
  288.       Left            =   4950
  289.       TabIndex        =   0
  290.       Top             =   75
  291.       Width           =   1305
  292.    End
  293.    Begin VB.ListBox List1 
  294.       Height          =   450
  295.       Left            =   2580
  296.       TabIndex        =   25
  297.       Top             =   3030
  298.       Width           =   1215
  299.    End
  300. Attribute VB_Name = "Form1"
  301. Attribute VB_GlobalNameSpace = False
  302. Attribute VB_Creatable = False
  303. Attribute VB_PredeclaredId = True
  304. Attribute VB_Exposed = False
  305. Private Sub cmdBrowse_Click()
  306. Form3.Show
  307. End Sub
  308. Private Sub cmdFind_Click()
  309.     ListView1.ListItems.Clear 'CLEAR ALL THE PREV LISTITEMS FIRST
  310.     StatusBar1.Panels(1).Text = ""
  311.     If txtExt = "" Then txtExt = "*.*"
  312.     Me.Caption = Me.Caption & "Files named " & txtExt
  313.     GetJobFiles txtPath, txtExt
  314.     StatusBar1.Panels(1).Text = ListView1.ListItems.Count & " file(s) found" 'GET THE TOTAL NUMBER OF FILES FROM SEARCH
  315. End Sub
  316. Private Sub cmdUnload_Click()
  317.     Unload Me
  318. End Sub
  319. Private Sub cmdClear_Click()
  320. Dim ctrl As Control
  321. On Error Resume Next
  322. For Each ctrl In Me 'TO CLEAR ALL THE CONTROL TEXT PROPERTY
  323.     ctrl.Text = ""
  324. Next ctrl
  325. List1.Clear
  326. ListView1.ListItems.Clear
  327. txtExt.SetFocus
  328. End Sub
  329. Private Sub Form_Load()
  330. 'ADD THE COLUMNHEADERS FOR THE LISTVIEW CONTROL
  331.     ListView1.ColumnHeaders.Add 1, "name", "Name"
  332.     ListView1.ColumnHeaders.Add 2, "infolder", "In Folder"
  333.     ListView1.ColumnHeaders.Add 3, "size", "Size"
  334.     ListView1.ColumnHeaders.Add 4, "type", "Type"
  335.     ListView1.ColumnHeaders.Add 5, "date", "Date Modified"
  336. End Sub
  337. Private Function GetJobFiles(drivepath As String, ext As String) As Boolean
  338. Dim XDir() As String 'TO STORE THE LIST OF THE DIRECTORIES
  339. Dim tmpdir As String 'TO STORE DIR NAME
  340. Dim DirCount As Integer 'TOTAL OF DIR IN XDIR()
  341. Dim X As Integer
  342. On Error Resume Next
  343. 'Initialises Variables
  344. DirCount = 0
  345. ReDim XDir(0) As String
  346. XDir(DirCount) = ""
  347. Getfindfiles drivepath
  348. If Right(drivepath, 1) <> "\" Then
  349.     drivepath = drivepath & "\"
  350. End If
  351. DoEvents
  352. tmpdir = Dir(drivepath, vbDirectory)
  353. Do While tmpdir <> ""
  354.    If tmpdir <> "." And tmpdir <> ".." Then
  355.        If (GetAttr(drivepath & tmpdir) And vbDirectory) = vbDirectory Then
  356.             Getfindfiles drivepath & tmpdir
  357.             XDir(DirCount) = drivepath & tmpdir & "\"
  358.             DirCount = DirCount + 1
  359.             ReDim Preserve XDir(DirCount) As String
  360.             
  361.         End If
  362.     End If
  363.     tmpdir = Dir
  364. 'Recursive searches through all sub directories
  365. For X = 0 To (UBound(XDir) - 1)
  366.     GetJobFiles1 XDir(X)
  367. Next X
  368. End Function
  369. Private Function GetJobFiles1(drivepath As String) As Boolean
  370. Dim XDir() As String
  371. Dim tmpdir As String
  372. Dim DirCount As Integer
  373. Dim X As Integer
  374. 'On Error Resume Next
  375. 'Initialises Variables
  376. DirCount = 0
  377. ReDim XDir(0) As String
  378. XDir(DirCount) = ""
  379. If Right(drivepath, 1) <> "\" Then
  380.     drivepath = drivepath & "\"
  381. End If
  382. DoEvents
  383. 'If ListView1.ListItems.Count > 100 Then Exit Function
  384. tmpdir = Dir(drivepath, vbDirectory)
  385. Do While tmpdir <> ""
  386.    If tmpdir <> "." And tmpdir <> ".." Then
  387.        If (GetAttr(drivepath & tmpdir) And vbDirectory) = vbDirectory Then
  388.             Getfindfiles drivepath & tmpdir
  389.             XDir(DirCount) = drivepath & tmpdir & "\"
  390.             DirCount = DirCount + 1
  391.             ReDim Preserve XDir(DirCount) As String
  392.         End If
  393.     End If
  394.     tmpdir = Dir
  395. 'Recursive searches through all sub directories
  396. For X = 0 To (UBound(XDir) - 1)
  397.     GetJobFiles1 XDir(X)
  398. Next X
  399. End Function
  400. Public Function Getfindfiles(driv As String)
  401. Dim fs, fsFolder, fsFileList, fsFile, ls As ListItem
  402. Static fsFilecounter As Long
  403. Set fs = CreateObject("Scripting.FileSystemObject") 'INIALIZE THE FILESYSTEM VARIABLES
  404. Set fsFolder = fs.GetFolder(driv & "\") 'FOLDER
  405. Set fsFileList = fsFolder.Files 'TOTAL FILES IN THAT FOLDER
  406. For Each fsFile In fsFileList
  407. If txtExt = "*.*" Then 'FIRST CHECK THE EXT
  408.    If cboSize.Text = "" And cboDate = "" Then 'CHECK WHETHER THE CRITERIA FOR SIZE AND DATE IS GIVEN
  409.         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  410.         ls.SubItems(1) = driv 'PATH
  411.         ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB" 'GET THE SIZE IN BYTES AND LATER DIVIDE BY 1024 TO CONVERT INTO KB
  412.         If Round(fsFile.Size / 1024) = 0 Then
  413.             ls.SubItems(2) = fsFile.Size & "Bytes"
  414.         End If
  415.         ls.SubItems(3) = fsFile.Type 'FILE TYPE
  416.         ls.SubItems(4) = fsFile.DateLastModified 'DATE MODIFIED
  417.     ElseIf cboSize.Text = "" And cboDate.Text <> "" Then
  418.         If cboDate.Text = "Modified" Then
  419.            If CDate(txtFrom) <= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  420.                If CDate(txtTo) >= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  421.                    Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  422.                    ls.SubItems(1) = driv
  423.                    ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  424.                    If Round(fsFile.Size / 1024) = 0 Then
  425.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  426.                     End If
  427.                    ls.SubItems(3) = fsFile.Type
  428.                    Dim f As File
  429.                    ls.SubItems(4) = fsFile.DateLastModified
  430.                End If
  431.            End If
  432.         ElseIf cboDate.Text = "Created" Then
  433.             If CDate(txtFrom) <= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  434.                 If CDate(txtTo) >= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  435.                     Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  436.                     ls.SubItems(1) = driv
  437.                     ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  438.                     If Round(fsFile.Size / 1024) = 0 Then
  439.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  440.                     End If
  441.                     ls.SubItems(3) = fsFile.Type
  442.                     ls.SubItems(4) = fsFile.DateCreated
  443.                 End If
  444.             End If
  445.         ElseIf cboDate.Text = "Lastaccessed" Then
  446.             If CDate(txtFrom) <= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  447.                 If CDate(txtTo) >= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  448.                     Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  449.                     ls.SubItems(1) = driv
  450.                     ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  451.                     If Round(fsFile.Size / 1024) = 0 Then
  452.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  453.                     End If
  454.                     ls.SubItems(3) = fsFile.Type
  455.                     ls.SubItems(4) = fsFile.DateLastAccessed
  456.                 End If
  457.             End If
  458.         End If
  459.     ElseIf cboDate = "" And cboSize <> "" Then
  460.        If cboSize.Text = "AtMost" Then
  461.             If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  462.                 Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  463.                 ls.SubItems(1) = driv
  464.                 ls.SubItems(2) = Round(fsFile.Size / 1024) & "Bytes"
  465.                 If Round(fsFile.Size / 1024) = 0 Then
  466.                     ls.SubItems(2) = fsFile.Size & "Bytes"
  467.                 End If
  468.                 ls.SubItems(3) = fsFile.Type
  469.                 ls.SubItems(4) = fsFile.DateLastModified
  470.             End If
  471.         ElseIf cboSize.Text = "AtLeast" Then
  472.             If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  473.                 Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  474.                 ls.SubItems(1) = driv
  475.                 ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  476.                 If Round(fsFile.Size / 1024) = 0 Then
  477.                     ls.SubItems(2) = fsFile.Size & "Bytes"
  478.                 End If
  479.                 ls.SubItems(3) = fsFile.Type
  480.                 ls.SubItems(4) = fsFile.DateLastModified
  481.             End If
  482.         End If
  483.     ElseIf cboDate <> "" And cboSize <> "" Then
  484.         If cboDate.Text = "Modified" Then
  485.            If CDate(txtFrom) <= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  486.                If CDate(txtTo) >= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  487.                 If cboSize.Text = "AtMost" Then
  488.                     If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  489.                         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  490.                         ls.SubItems(1) = driv
  491.                         ls.SubItems(2) = Round(fsFile.Size / 1024) & "Bytes"
  492.                         If Round(fsFile.Size / 1024) = 0 Then
  493.                             ls.SubItems(2) = fsFile.Size & "Bytes"
  494.                         End If
  495.                         ls.SubItems(3) = fsFile.Type
  496.                         ls.SubItems(4) = fsFile.DateLastModified
  497.                     End If
  498.                 ElseIf cboSize.Text = "AtLeast" Then
  499.                     If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  500.                         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  501.                         ls.SubItems(1) = driv
  502.                         ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  503.                         If Round(fsFile.Size / 1024) = 0 Then
  504.                             ls.SubItems(2) = fsFile.Size & "Bytes"
  505.                         End If
  506.                         ls.SubItems(3) = fsFile.Type
  507.                         ls.SubItems(4) = fsFile.DateLastModified
  508.                     End If
  509.                 End If
  510.                End If
  511.          End If
  512.         ElseIf cboDate.Text = "Created" Then
  513.             If CDate(txtFrom) <= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  514.                 If CDate(txtTo) >= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  515.                     If cboSize.Text = "AtMost" Then
  516.                         If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  517.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  518.                             ls.SubItems(1) = driv
  519.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "Bytes"
  520.                             If Round(fsFile.Size / 1024) = 0 Then
  521.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  522.                             End If
  523.                             ls.SubItems(3) = fsFile.Type
  524.                             ls.SubItems(4) = fsFile.DateCreated
  525.                         End If
  526.                     ElseIf cboSize.Text = "AtLeast" Then
  527.                         If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  528.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  529.                             ls.SubItems(1) = driv
  530.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  531.                             If Round(fsFile.Size / 1024) = 0 Then
  532.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  533.                             End If
  534.                             ls.SubItems(3) = fsFile.Type
  535.                             ls.SubItems(4) = fsFile.DateCreated
  536.                         End If
  537.                     End If
  538.                 End If
  539.             End If
  540.         ElseIf cboDate.Text = "Lastaccessed" Then
  541.             If CDate(txtFrom) <= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  542.                 If CDate(txtTo) >= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  543.                    If cboSize.Text = "AtMost" Then
  544.                         If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  545.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  546.                             ls.SubItems(1) = driv
  547.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "Bytes"
  548.                             If Round(fsFile.Size / 1024) = 0 Then
  549.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  550.                             End If
  551.                             ls.SubItems(3) = fsFile.Type
  552.                             ls.SubItems(4) = fsFile.DateLastAccessed
  553.                         End If
  554.                     ElseIf cboSize.Text = "AtLeast" Then
  555.                         If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  556.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  557.                             ls.SubItems(1) = driv
  558.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  559.                             If Round(fsFile.Size / 1024) = 0 Then
  560.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  561.                             End If
  562.                             ls.SubItems(3) = fsFile.Type
  563.                             ls.SubItems(4) = fsFile.DateLastAccessed
  564.                         End If
  565.                     End If
  566.                 End If
  567.             End If
  568.         End If
  569.     End If
  570. ElseIf LCase(Right(fsFile.Name, 3)) = LCase(Right(txtExt, 3)) Then 'IF AN EXT IS GIVEN
  571.     If txtText <> "" Then
  572.         checkfile fsFile.Name, driv, txtText 'FOR CONTAINING TEXT CRITERIA
  573.     End If
  574.     If cboSize.Text = "" And cboDate = "" And txtText = "" Then
  575.         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  576.         ls.SubItems(1) = driv
  577.         ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  578.         If Round(fsFile.Size / 1024) = 0 Then
  579.             ls.SubItems(2) = fsFile.Size & "Bytes"
  580.         End If
  581.         ls.SubItems(3) = fsFile.Type
  582.         ls.SubItems(4) = fsFile.DateLastModified
  583.     ElseIf cboSize.Text = "" And cboDate.Text <> "" Then
  584.         If cboDate.Text = "Modified" Then
  585.            If CDate(txtFrom) <= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  586.                If CDate(txtTo) >= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  587.                    Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  588.                    ls.SubItems(1) = driv
  589.                    ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  590.                    If Round(fsFile.Size / 1024) = 0 Then
  591.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  592.                     End If
  593.                    ls.SubItems(3) = fsFile.Type
  594.                    ls.SubItems(4) = fsFile.DateLastModified
  595.                End If
  596.            End If
  597.         ElseIf cboDate.Text = "Created" Then
  598.             If CDate(txtFrom) <= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  599.                 If CDate(txtTo) >= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  600.                     Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  601.                     ls.SubItems(1) = driv
  602.                     ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  603.                     If Round(fsFile.Size / 1024) = 0 Then
  604.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  605.                     End If
  606.                     ls.SubItems(3) = fsFile.Type
  607.                     ls.SubItems(4) = fsFile.DateCreated
  608.                 End If
  609.             End If
  610.         ElseIf cboDate.Text = "Lastaccessed" Then
  611.             If CDate(txtFrom) <= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  612.                 If CDate(txtTo) >= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  613.                     Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  614.                     ls.SubItems(1) = driv
  615.                     ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  616.                     If Round(fsFile.Size / 1024) = 0 Then
  617.                         ls.SubItems(2) = fsFile.Size & "Bytes"
  618.                     End If
  619.                     ls.SubItems(3) = fsFile.Type
  620.                     ls.SubItems(4) = fsFile.DateLastAccessed
  621.                 End If
  622.             End If
  623.         End If
  624.     ElseIf cboDate = "" And cboSize <> "" Then
  625.        If cboSize.Text = "AtMost" Then
  626.             If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  627.                 Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  628.                 ls.SubItems(1) = driv
  629.                 ls.SubItems(2) = Round(fsFile.Size / 1024) & "Bytes"
  630.                 If Round(fsFile.Size / 1024) = 0 Then
  631.                     ls.SubItems(2) = fsFile.Size & "Bytes"
  632.                 End If
  633.                 ls.SubItems(3) = fsFile.Type
  634.                 ls.SubItems(4) = fsFile.DateLastModified
  635.             End If
  636.         ElseIf cboSize.Text = "AtLeast" Then
  637.             If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  638.                 Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  639.                 ls.SubItems(1) = driv
  640.                 ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  641.                 If Round(fsFile.Size / 1024) = 0 Then
  642.                     ls.SubItems(2) = fsFile.Size & "Bytes"
  643.                 End If
  644.                 ls.SubItems(3) = fsFile.Type
  645.                 ls.SubItems(4) = fsFile.DateLastModified
  646.             End If
  647.         End If
  648.     ElseIf cboDate <> "" And cboSize <> "" Then
  649.         If cboDate.Text = "Modified" Then
  650.            If CDate(txtFrom) <= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  651.                If CDate(txtTo) >= CDate(Format(fsFile.DateLastModified, "mm-dd-yy")) Then
  652.                 If cboSize.Text = "AtMost" Then
  653.                     If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  654.                         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  655.                         ls.SubItems(1) = driv
  656.                         ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  657.                         If Round(fsFile.Size / 1024) = 0 Then
  658.                             ls.SubItems(2) = fsFile.Size & "Bytes"
  659.                         End If
  660.                         ls.SubItems(3) = fsFile.Type
  661.                         ls.SubItems(4) = fsFile.DateLastModified
  662.                     End If
  663.                 ElseIf cboSize.Text = "AtLeast" Then
  664.                     If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  665.                         Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  666.                         ls.SubItems(1) = driv
  667.                         ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  668.                         If Round(fsFile.Size / 1024) = 0 Then
  669.                             ls.SubItems(2) = fsFile.Size & "Bytes"
  670.                         End If
  671.                         ls.SubItems(3) = fsFile.Type
  672.                         ls.SubItems(4) = fsFile.DateLastModified
  673.                     End If
  674.                 End If
  675.                End If
  676.          End If
  677.         ElseIf cboDate.Text = "Created" Then
  678.             If CDate(txtFrom) <= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  679.                 If CDate(txtTo) >= CDate(Format(fsFile.DateCreated, "mm-dd-yy")) Then
  680.                     If cboSize.Text = "AtMost" Then
  681.                         If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  682.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  683.                             ls.SubItems(1) = driv
  684.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  685.                             If Round(fsFile.Size / 1024) = 0 Then
  686.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  687.                             End If
  688.                             ls.SubItems(3) = fsFile.Type
  689.                             ls.SubItems(4) = fsFile.DateCreated
  690.                         End If
  691.                     ElseIf cboSize.Text = "AtLeast" Then
  692.                         If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  693.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  694.                             ls.SubItems(1) = driv
  695.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  696.                             If Round(fsFile.Size / 1024) = 0 Then
  697.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  698.                             End If
  699.                             ls.SubItems(3) = fsFile.Type
  700.                             ls.SubItems(4) = fsFile.DateCreated
  701.                         End If
  702.                     End If
  703.                 End If
  704.             End If
  705.         ElseIf cboDate.Text = "Lastaccessed" Then
  706.             If CDate(txtFrom) <= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  707.                 If CDate(txtTo) >= CDate(Format(fsFile.DateLastAccessed, "mm-dd-yy")) Then
  708.                    If cboSize.Text = "AtMost" Then
  709.                         If Round(fsFile.Size / 1024) <= CInt(txtSize) Then
  710.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  711.                             ls.SubItems(1) = driv
  712.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  713.                             If Round(fsFile.Size / 1024) = 0 Then
  714.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  715.                             End If
  716.                             ls.SubItems(3) = fsFile.Type
  717.                             ls.SubItems(4) = fsFile.DateLastAccessed
  718.                         End If
  719.                     ElseIf cboSize.Text = "AtLeast" Then
  720.                         If Round(fsFile.Size / 1024) >= CInt(txtSize) Then
  721.                             Set ls = ListView1.ListItems.Add(1, driv & fsFile.Name, fsFile.Name)
  722.                             ls.SubItems(1) = driv
  723.                             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  724.                             If Round(fsFile.Size / 1024) = 0 Then
  725.                                 ls.SubItems(2) = fsFile.Size & "Bytes"
  726.                             End If
  727.                             ls.SubItems(3) = fsFile.Type
  728.                             ls.SubItems(4) = fsFile.DateLastAccessed
  729.                         End If
  730.                     End If
  731.                 End If
  732.             End If
  733.         End If
  734.     End If
  735. End If
  736. End Function
  737. Public Function GetSelectedFile(strPath As String, listnum As String) As String
  738.     If Right(strPath, 1) <> "\" Then
  739.         GetSelectedFile = strPath & "\" & listnum
  740.     Else
  741.         GetSelectedFile = strPath & listnum
  742.     End If
  743. End Function
  744. Private Sub checkfile(listnum As String, drivpath As String, searchfor As String)
  745. Dim strSearchFor$, intFileCount%, intListCount%, strGsearch$
  746. Dim gFindPosition&, strFound$, ls As ListItem
  747. Dim fs, fsFolder, fsFileList, fsFile
  748. Set fs = CreateObject("Scripting.FileSystemObject")
  749. Set fsFolder = fs.GetFolder(drivpath & "\")
  750. Set fsFileList = fsFolder.Files
  751. For Each fsFile In fsFileList
  752.     If fsFile.Name = listnum Then
  753.         strSearchFor$ = searchfor 'AS above
  754.             
  755.         Open GetSelectedFile(drivpath, listnum) For Binary As 1 'Loadfile into strgsearch$
  756.         strGsearch$ = String(LOF(1), Chr$(0))
  757.         Get 1, , strGsearch$
  758.         Close 1
  759.         
  760.         If chkMatchCase.Value = vbChecked Then 'If matchcase checkbox is cheched then
  761.             strGsearch$ = strGsearch$
  762.         Else 'If it`s not checked then
  763.             strGsearch$ = LCase(strGsearch$)
  764.         End If
  765.         
  766.         gFindPosition& = InStr(strGsearch$, strSearchFor$) 'Find position of strsearchfor$ in rtboxsearch$
  767.         If gFindPosition& <> 0 Then
  768.             strFound$ = Mid(strGsearch$, gFindPosition&, Len(strSearchFor$)) 'If string found the extract string into strfound$
  769.         End If
  770.         
  771.         If strFound$ = strSearchFor$ Then 'If the string is found then
  772.            Set ls = ListView1.ListItems.Add(1, drivpath & fsFile.Name, fsFile.Name)
  773.             ls.SubItems(1) = drivpath
  774.             ls.SubItems(2) = Round(fsFile.Size / 1024) & "KB"
  775.             If Round(fsFile.Size / 1024) = 0 Then
  776.                 ls.SubItems(2) = fsFile.Size & "Bytes"
  777.             End If
  778.             ls.SubItems(3) = fsFile.Type
  779.             ls.SubItems(4) = fsFile.DateCreated
  780.         End If
  781.     End If
  782. strGsearch$ = "" 'Clear the variable for the next file
  783. strFound$ = "" 'Clear the variable for the next file
  784. End Sub
  785. Private Sub Form_Resize()
  786. ListView1.Width = Me.Width
  787. End Sub
  788. Private Sub txtSize_KeyPress(KeyAscii As Integer)
  789. If Not (IsNumeric(Chr(KeyAscii)) Or KeyAscii = vbKeyBack) Then 'TO GET ONLY NUMERIC INPUT
  790.     KeyAscii = 0
  791. End If
  792. End Sub
  793.