炉石传说有手机版吗:VB如何查找某一个文件夹下所有文件名包含某个汉字的doc文件

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 21:07:55
比如DOS文件夹下包含100个doc文件,我想从这100文件中找到文件名里有”的”字的所有文件,并把找到的这些文件名返回给一个list或者combo里面,供用户选择
VB如何实现?
请高手赐教,给与代码

举例说明,自己根据这个再改改

Dim MyFile As String
Dim strPath As String
Dim strFile As String
dim tempList as listitem

''strPath为文件夹的路径,strFile为文件夹里的文件
strPath = "C:\Temp"
strFile = strPath & "\*.doc"

MyFile = Dir(strFile, vbNormal)''获得符合条件的文件名
Do While MyFile<> "" ''循环查找
if instr(1,MyFile,"的")>0 then '判断当前文件是否包含“的“,包含则>0
set templist=list.listitem.add(,,myfile) ''添加到list列表
end if
MyFile= Dir''如果和上次一样,DIR可以这么省写
Loop
End If

用Dir函数.
用统配符去查,或者把.doc都查出来,循环里判断文件名的内容。