'在pic文件夹下有若干个名为Sc***.Dps的文件,要将这些文件读入数组处理,得不到文件名,请帮忙看看
我分不高,解决后全送了Dim FileName As String
Dim strFile() As String
Dim n As long,i As LongFilePath = App.Path & "\Pic\"
FileName = Dir(FilePath & "Sc*.Dps")n = o
If FileName <> "" Then
Do
    DoEvents
    n = n + 1
    FileName = Dir()
Loop Until FileName = ""
End IfList1.Clear
Text1.Text = n '显示文件数(可以正常显示)ReDim strFile(1 To n) As String
For i = 1 To n
strFile(i) = FileName  '问题应该是出在这儿
i = i + 1
List1.AddItem strFile(i)NextEnd Sub

解决方案 »

  1.   

    我猜你是要实现这样的效果吧Private Sub Command1_Click()
        Dim FileName     As String
        Dim filepath     As String
        Dim strFile()    As String
        Dim n            As Long
        Dim i            As Long
        
        filepath = App.Path & "\Pic\"
        FileName = Dir(filepath & "Sc*.Dps")
        
        n = 0
        While FileName <> ""
            DoEvents
            n = n + 1
            ReDim Preserve strFile(n)
            strFile(n) = FileName
            FileName = Dir()
        Wend
        
        List1.Clear
        Text1.Text = n
        
        For i = 1 To n
            List1.AddItem strFile(i)
        Next
    End Sub