11530.html

来自「以电子书的形式收集了VB一些常见问题解决方法,可以很方便的查找自己需要解决的问题」· HTML 代码 · 共 23 行

HTML
23
字号
<html>
  <head>
    <title>Re: 搜寻档案!!</title>
  </head>
  <body bgcolor="#FFFFFF" vlink="#808080">
    <center>
      <h1>Re: 搜寻档案!!</h1>
    </center>
<hr size=7 width=75%>

<hr size=7 width=75%><p>
Posted by <a href="mailto:winntuser@hotmAail.com">Windows NT user</a> on March 30, 1999 at 18:12:47:<p>
In Reply to: <a href="11522.html">搜寻档案!!</a> posted by 阿亮 on March 30, 1999 at 14:56:10:<p>
: 如何利用vb6.0来搜寻某档案,是否存在,及接收传回来的参数!!<br>: 多谢<p>'in modules<br>Option Explicit<br>Public FoundFile() As String '存放传回值的字串阵列<br>Private ntx As Long<p>Public Sub FindFile(StartPath As String, fileMask As String)<br>ntx = 0<br>Call GetDirPath(StartPath, fileMask)<br>End Sub<p>Private Sub GetDirPath(CurrentPath As String, ByVal SearFile As String)<br>    Dim nI As Integer, nDirectory As Integer, i As Long<br>    Dim sFileName As String, sDirectoryList() As String<br>    'First list all normal files in this directory<br>    sFileName = Dir(CurrentPath, vbHidden Or vbDirectory Or vbReadOnly Or vbSystem)<br>    Do Until sFileName = ""<br>       If UCase(sFileName) Like UCase(SearFile) Then<br>          i = GetAttr(CurrentPath + sFileName)<br>          If (i And vbDirectory) = 0 Then<br>              ReDim Preserve FoundFile(ntx)<br>              FoundFile(ntx) = CurrentPath + sFileName<br>              ntx = ntx + 1<br>          End If<br>       End If<br>       If sFileName <> "." And sFileName <> ".." Then<br>          On Error GoTo e<br>          'Ignore nondirectories<br>          If GetAttr(CurrentPath & sFileName) And vbDirectory Then<p>             nDirectory = nDirectory + 1<br>             ReDim Preserve sDirectoryList(nDirectory)<br>             sDirectoryList(nDirectory) = CurrentPath & sFileName<br>            End If<br>e:<br>        End If<br>        On Error Resume Next<br>       sFileName = Dir<br>    Loop<br>    'Recursively process each directory<br>     For nI = 1 To nDirectory<br>         GetDirPath sDirectoryList(nI) & "\", SearFile<br>     Next nI<br>End Sub<p><p><br>e.g:FindFile *.txt , c:\<p>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 11530-->
</ul><!--end: 11530-->
<br><hr size=7 width=75%><p>

</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?