以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] 查找功能 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=169277) |
-- 作者:sanny -- 发布时间:2021/6/9 19:12:00 -- [求助] 查找功能 老师, 针对以下代码有2个问题: 1. 按照以下它只能搜索Z:\\GSS Shanghai\\\\Quality\\Checkreports下层目录中所有的相应文件, 如何让它也再找下下层目录中的文件。 2. 只能找 S.xlsx的文件, 如何找这样的文件,如 s_a template.xlxs 或 s_atemplete .xlxs 这类文件。 用 files & "\\" & S &“_a*templete*" & ".xlsx",不对,谢谢。 If e.Col.name = "CL" Then Select Case left(S,2) Case "AR" For Each files As String In FileSys.GetDirectories("Z:\\GSS Shanghai\\\\Quality\\Checkreports") Dim fl As String = files & "\\" & S & ".xlsx" If FileSys.FileExists(fl) Then Dim Proc As New Process Proc.File = fl Proc.Start() Return End If Next msgbox ("没有找到相关Checklist模板!") End Select End If [此贴子已经被作者于2021/6/9 19:13:08编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/6/10 8:59:00 -- If e.Col.name = "CL" Then Select Case left(S,2) Case "AR" For Each files As String In FileSys.GetDirectories("Z:\\GSS Shanghai\\\\Quality\\Checkreports") For Each File As String In FileSys.GetFiles(files ) Dim name As String = FileSys.GetName(file) If name Like "s_a*" AndAlso name Like "*.xlsx" Then Dim Proc As New Process Proc.File = file Proc.Start() Return End If Next For Each files2 As String In FileSys.GetDirectories(files ) For Each File2 As String In FileSys.GetFiles(files2 ) Dim name2 As String = FileSys.GetName(file2) If name2 Like "s_a*" AndAlso name2 Like "*.xlsx" Then Dim Proc As New Process Proc.File = file2 Proc.Start() Return End If Next Next Next msgbox ("没有找到相关Checklist模板!") End Select End If
|
-- 作者:sanny -- 发布时间:2021/6/10 21:13:00 -- 老师,S是变更,我改成如下,但是太慢了,可以帮忙优化一下吗 ? If e.Col.name = "CL" Then Select Case left(S,2) Case "AR" For Each files As String In FileSys.GetDirectories("Z:\\GSS Shanghai\\Quality\\02 Checkreports") For Each File As String In FileSys.GetFiles(files ) Next For Each files2 As String In FileSys.GetDirectories(files ) For Each File2 As String In FileSys.GetFiles(files2 ) Dim name2 As String = FileSys.GetName(file2) If name2 Like S &"*template*.xlsx" Then Dim Proc As New Process Proc.File = file2 Proc.Start() Return End If Next Next Next msgbox ("没有找到相关Checklist模板!") End Select End If |
-- 作者:有点蓝 -- 发布时间:2021/6/10 21:27:00 -- If e.Col.name = "CL" Then Select Case left(S,2) Case "AR" For Each files As String In FileSys.GetDirectories("Z:\\GSS Shanghai\\\\Quality\\Checkreports") For Each File As String In FileSys.GetFiles(files ) Dim name As String = FileSys.GetName(file) If name Like s & "_a*" AndAlso name Like "*.xlsx" Then Dim Proc As New Process Proc.File = file Proc.Start() Return End If Next For Each files2 As String In FileSys.GetDirectories(files ) For Each File2 As String In FileSys.GetFiles(files2 ) Dim name2 As String = FileSys.GetName(file2) If name2 Like s & "_a*" AndAlso name2 Like "*.xlsx" Then Dim Proc As New Process Proc.File = file2 Proc.Start() Return End If Next Next Next msgbox ("没有找到相关Checklist模板!") End Select End If
|