English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

我想做ㄍ搜尋程式 例如我今天想知道[lineage]這ㄍ檔名ㄉ所在位置...
該怎弄ㄋ...我買ㄌ一本vb看....還是一頭霧水......>\"<

2006-02-25 16:15:54 · 1 個解答 · 發問者 楓玥ˋˊ 1 in 電腦與網際網路 程式設計

1 個解答

Dim R As Object, D As DriveListBox, S As String, L As ListBox, WithEvents C As CommandButton

Private Sub C_Click()
Dim I As Integer, K As Object, P As String
S = InputBox("請輸入欲搜尋文字")
If S = "" Then Exit Sub
For I = 0 To D.ListCount - 1
  DoEvents
  Set K = R.GetDrive(Left(D.List(I), InStr(D.List(I), ":")))
  If K.IsReady Then
   P = R.GetDriveName(K):P = IIf(Right(P, 1) = "\", P, P & "\")
   FF R.GetFolder(P):HF R.GetFolder(P)
  End If
Next
Caption = L.ListCount & "個檔案"
End Sub

Sub HF(F As Object) '搜尋子資料夾副程式
Dim X As Object
On Error Resume Next
Caption = F.Path
For Each X In F.SubFolders
  FF X:HF X
Next
End Sub

Sub FF(A As Object) '搜尋檔案副程式
Dim F As Object
For Each F In A.Files
  'If UCase(R.GetBaseName(F.Path)) = UCase(S) Then '字串完全相同
  If InStr(1, R.GetBaseName(F.Path), S, vbTextCompare) Then '內含相同文字
   L.AddItem F.Path
  End If
  DoEvents
Next
End Sub

Private Sub Form_Load()
Height = 7545: Width = 10000
Set D = Controls.Add("VB.DriveListBox", "D")
Set R = CreateObject("Scripting.FileSystemObject")
Set L = Controls.Add("VB.ListBox", "L")
L.Visible = True: L.Height = 6540: L.Width = ScaleWidth
Set C = Controls.Add("VB.CommandButton", "C")
C.Visible = True: C.Caption = "搜尋": C.Top = 6600
End Sub

2006-02-25 20:38:33 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers