请高手帮忙修改下代码,实在想不出来该怎么弄,网上搜了一天也没有
关键是几个控件和数组之间的对应关系,怎么也想不通啊,找不到例子,请求帮助,谢谢了!
Option Explicit
Dim FileInfo() As String
Private Sub Command1_Click()
On Error GoTo userCanceled
Dim i As Integer
Dim litem As ListItems
With CommonDialog1
.CancelError = True
.Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
.Filter = "文本文件(.txt)|*.txt"
.ShowOpen
GetFileInfo (.FileName)
End With
ListView1.ListItems.Clear
For i = 1 To UBound(FileInfo)
ListView1.ListItems.Add (i) ' 这里怎么添加文件名呢?网上和MSDN里讲的都是和数据库 ' ListView1.ListSubItems(0) = i ' 绑定的,而我需要的都是动态不固定的,不需要数据库文件的
' ,不知该如何设置对象
' ListView1.ListSubItems(1) = FileInfo(i)
Next
'Label2 = FileInfo(0) ' 还有就是ListView1列表里的各条文件名如何与原文件导入的
userCanceled: ' 数组相对应,当我勾选ListView1列表里的复选框时,同时选
End Sub ' 择原文件内容的数组???
Private Sub GetFileInfo(Source As String)
Dim t As Integer
FileInfo = Split(Source, Chr(0))
If UBound(FileInfo) = 0 Then
ReDim Preserve FileInfo(1)
t = InStrRev(FileInfo(0), "\")
FileInfo(1) = Mid(FileInfo(0), t + 1)
FileInfo(0) = Left(FileInfo(0), t)
Else
If Right(FileInfo(0), 1) <> "\" Then FileInfo(0) = FileInfo(0) & "\"
End If
End Sub
如图是最终形成的样子,请高手指教了。谢谢!
[此贴子已经被作者于2007-8-7 17:06:23编辑过]