hi......
i am using ms access 2003,vb6
i have a form.
in that i have 2 buttons
1. start search
2 stop search
when i click the "start search" button the fucntion SearchSystem() is called, it will search for a particular file in the computer(search es entire drives).
the button "stop search" is intended to stop the search.
but while the search is going on, i could not click "stop search", it is not enabled to click while the search is going on?
how do i approach to stop the search?
[CODE=vb]Function SearchSystem(Dr iveTypes As Integer, FileSpec As String, Optional oFolder = Empty) As Integer
Dim fs As FileSystemObjec t
Dim dc As Drives
Dim oDrive As Drive
Dim ofld As Folder
Dim file
Dim subdirs As New Collection
Dim subdir
Dim st As String
Set fs = CreateObject("S cripting.FileSy stemObject")
Set dc = fs.Drives
On Error GoTo errorhandler:
If oFolder <> "" Then
If cap = 1 Then
Label11.caption = " The applicaion is being searced for in " & oFolder
Me.Refresh
Me.Repaint
Me.Refresh
ElseIf cap = 2 Then
Label11.caption = " The application is being searched for in " & oFolder
Me.Refresh
Me.Repaint
Me.Refresh
End If
file = Dir$(oFolder & FileSpec)
Do While Len(file)
'File found
file = oFolder & file
If InStr(1, file, "IFs.exe") Then
st = Replace(file, "IFs.exe", "")
ChDir st
Shell file, vbNormalFocus
glob = glob + 1
Exit Function
ElseIf InStr(1, file, "Wdi32.exe" ) Then
st = Replace(file, "Wdi32.exe" , "")
ChDir st
Shell file, vbNormalFocus
glob = glob + 1
Exit Function
End If
'Exit Sub
Debug.Print file
file = Dir$()
Loop
file = Dir$(oFolder & "*.*", vbDirectory)
Do While Len(file)
' we've found a new directory
If file = "." Or file = ".." Then
' exclude "." and ".."
ElseIf (GetAttr(oFolde r & file) And vbDirectory) = 0 Then
' ignore regular files
Else
' this is a directory, include the path in the collection
subdirs.Add oFolder & file
End If
' get next directory
file = Dir$()
Loop
For Each subdir In subdirs
If glob = 0 Then
Call SearchSystem(Dr iveTypes, FileSpec, subdir & "\")
Else
Exit Function
End If
Next
End If
If oFolder = "" Then
For Each oDrive In dc
'Use bitwise expression to see if Drivetype is one of the Drivetypes we wish to search
If (oDrive.DriveTy pe And DriveTypes) = oDrive.DriveTyp e Then
'MsgBox ("searching" )
'oDrive is a drive type we wish to search
Debug.Print "Searching: " & oDrive.path
If oDrive.IsReady Then Call SearchSystem(Dr iveTypes, FileSpec, oDrive.path & "\")
End If
Next 'oDrive
Debug.Print "finished"
End If
Set fs = Nothing
Set dc = Nothing
'Exit Sub
errorhandler:
If Err.Number = 75 Then
'Path/File access error (file locked for reading or doesn't exist?)
Debug.Print Err.Description
Resume Next
ElseIf Err.Number = 52 Then
End If
End Function[/CODE]
i am using ms access 2003,vb6
i have a form.
in that i have 2 buttons
1. start search
2 stop search
when i click the "start search" button the fucntion SearchSystem() is called, it will search for a particular file in the computer(search es entire drives).
the button "stop search" is intended to stop the search.
but while the search is going on, i could not click "stop search", it is not enabled to click while the search is going on?
how do i approach to stop the search?
[CODE=vb]Function SearchSystem(Dr iveTypes As Integer, FileSpec As String, Optional oFolder = Empty) As Integer
Dim fs As FileSystemObjec t
Dim dc As Drives
Dim oDrive As Drive
Dim ofld As Folder
Dim file
Dim subdirs As New Collection
Dim subdir
Dim st As String
Set fs = CreateObject("S cripting.FileSy stemObject")
Set dc = fs.Drives
On Error GoTo errorhandler:
If oFolder <> "" Then
If cap = 1 Then
Label11.caption = " The applicaion is being searced for in " & oFolder
Me.Refresh
Me.Repaint
Me.Refresh
ElseIf cap = 2 Then
Label11.caption = " The application is being searched for in " & oFolder
Me.Refresh
Me.Repaint
Me.Refresh
End If
file = Dir$(oFolder & FileSpec)
Do While Len(file)
'File found
file = oFolder & file
If InStr(1, file, "IFs.exe") Then
st = Replace(file, "IFs.exe", "")
ChDir st
Shell file, vbNormalFocus
glob = glob + 1
Exit Function
ElseIf InStr(1, file, "Wdi32.exe" ) Then
st = Replace(file, "Wdi32.exe" , "")
ChDir st
Shell file, vbNormalFocus
glob = glob + 1
Exit Function
End If
'Exit Sub
Debug.Print file
file = Dir$()
Loop
file = Dir$(oFolder & "*.*", vbDirectory)
Do While Len(file)
' we've found a new directory
If file = "." Or file = ".." Then
' exclude "." and ".."
ElseIf (GetAttr(oFolde r & file) And vbDirectory) = 0 Then
' ignore regular files
Else
' this is a directory, include the path in the collection
subdirs.Add oFolder & file
End If
' get next directory
file = Dir$()
Loop
For Each subdir In subdirs
If glob = 0 Then
Call SearchSystem(Dr iveTypes, FileSpec, subdir & "\")
Else
Exit Function
End If
Next
End If
If oFolder = "" Then
For Each oDrive In dc
'Use bitwise expression to see if Drivetype is one of the Drivetypes we wish to search
If (oDrive.DriveTy pe And DriveTypes) = oDrive.DriveTyp e Then
'MsgBox ("searching" )
'oDrive is a drive type we wish to search
Debug.Print "Searching: " & oDrive.path
If oDrive.IsReady Then Call SearchSystem(Dr iveTypes, FileSpec, oDrive.path & "\")
End If
Next 'oDrive
Debug.Print "finished"
End If
Set fs = Nothing
Set dc = Nothing
'Exit Sub
errorhandler:
If Err.Number = 75 Then
'Path/File access error (file locked for reading or doesn't exist?)
Debug.Print Err.Description
Resume Next
ElseIf Err.Number = 52 Then
End If
End Function[/CODE]
Comment