以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  文本框查询excel表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=195681)

--  作者:g1j2h3
--  发布时间:2025/2/28 12:47:00
--  文本框查询excel表
窗口中有一个文本框和一个按钮,我想通过按钮在指定文件夹下找到和文本框内容一样的excel表,并给其给其指定单元格内赋值,请大师指教
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
For Each File As String In FileSys.GetFiles("l:\\产品料单")
    If file.EndsWith(".xls") = "txt.xls" Then
        web.OfficeToolBar = True
        web.Address = "txt.xls"
    End If
Next

--  作者:有点蓝
--  发布时间:2025/2/28 13:20:00
--  
参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=149103
--  作者:g1j2h3
--  发布时间:2025/2/28 13:42:00
--  
请大师再指导下如何按文本框内容找到文件夹下匹配的excel表
--  作者:有点蓝
--  发布时间:2025/2/28 13:43:00
--  
匹配的excel的文件名称?还是匹配excel里面某个单元格?
--  作者:g1j2h3
--  发布时间:2025/2/28 13:51:00
--  
匹配excel的文件名称
--  作者:有点蓝
--  发布时间:2025/2/28 13:52:00
--  
For Each File As String In FileSys.GetFiles("l:\\产品料单")
    If file.EndsWith(txt & ".xls") Then
        web.OfficeToolBar = True
        web.Address = File 
exit for
    End If
Next

--  作者:g1j2h3
--  发布时间:2025/2/28 13:53:00
--  
谢谢蓝老师,我先试试
--  作者:g1j2h3
--  发布时间:2025/2/28 14:28:00
--  
如果我要查询("l:\\产品料单")及其子文件夹,该如何写代码
--  作者:有点蓝
--  发布时间:2025/2/28 16:30:00
--  
增加一个自定义函数名称:abc,函数内容

dim dir as string = args(0)
dim txt as string = args(1)
For Each File As String In FileSys.GetFiles(dir )
    If file.EndsWith(txt & ".xls") Then
       return File 
    End If
Next
For Each dir2 As String In FileSys.GetDirectories(dir) 如果有子目录
  dim s as string = 
Functions.Execute("abc",dir2 txt 
if s > "" then
retutn s
end if
Next
return ""

按钮
Dim txt As String = e.Form.Controls("TextBox1").Text
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
dim file as string =  Functions.Execute("abc","l:\\产品料单",txt )
    If file > "" Then
        web.OfficeToolBar = True
        web.Address = File 
else
msgbox("没有找到")
    End If

--  作者:g1j2h3
--  发布时间:2025/2/28 16:49:00
--  
非常感谢大师的指导