如下:
  一个文件夹中动态的生成TXT文件!
  现须实现如下的功能:
  --------------------------------------------------------------
 | 文件名           |文件的内容(这里对应的是相关文件的内容) |
 | 20041230.txt     | 20041230.txt的内容                      |    
 | 20041231.txt     |20041230.txt 的内容                      |  
 | 20050101.txt     |20041230.txt的内容                       |
 |................  | ....... .....                           |
------------------------------------------------------------------

解决方案 »

  1.   

    '调用方法:
    '++++++++++++++++++++++++++++++++++++
    '   Dim FileName() As String, i As Long
    '   GetFileList "c:\", FileName
    '   For i = 0 To UBound(FileName)
    '       Debug.Print FileName(i)
    '   Next i
    '++++++++++++++++++++++++++++++++++++
    Function GetFileList(ByVal Path As String, ByRef Filename() As String, Optional fExp As String = "*.*") As Boolean
        Dim fName As String, i As Long
        If right$(Path, 1) <> "\" Then Path = Path & "\"
        fName = Dir$(Path & fExp)
        i = 0
        Do While fName <> ""
            ReDim Preserve Filename(i) As String
            Filename(i) = fName
            fName = Dir$
            i = i + 1
        Loop
        If i <> 0 Then
            ReDim Preserve Filename(i - 1) As String
            GetFileList = True
        Else
            GetFileList = False
        End If
    End Function
      

  2.   

    再问:   读取出来的文件的顺序是不是都是不变的?   因为 我要将每次接收到的新文件的内容写入数据库!
       
       假如不变的话,就可以将文件数量保存在一个.ini 文件中,
       然后去就是比较 UBound(FileName)的值!
       大于的话就操作相关的文件内容!