以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]内部函数  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=104998)

--  作者:苏州老街
--  发布时间:2017/8/9 21:58:00
--  [求助]内部函数
老师,这个内部函数想搞成通用函数(不指定窗口和文本框控件)还有只显示项目下Attachments的路径。谢谢

Dim path As String = args(0)

For Each file As String In FileSys.GetFiles(path)
    Forms("应付款").Controls("TextBox2").Text &= vbcrlf & file
Next

For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("递归", p)
Next


[此贴子已经被作者于2017/8/10 8:48:46编辑过]

--  作者:有点甜
--  发布时间:2017/8/9 22:09:00
--  

1、递归,这样你就能得到所有的文件路径

 

内部函数 listfile

 

Dim pth As String = args(0)
Dim nms As List(of String) = args(1)
For Each fl As String In filesys.GetFiles(pth)
    nms.add(fl)
Next
For Each dr As String In FileSys.GetDirectories(pth)
    Functions.Execute("listfile",dr,nms)
Next


调用函数:
dim nms As New List(of string)
Functions.Execute("listfile","c:\\data",nms)

[此贴子已经被作者于2017/8/9 22:29:27编辑过]

--  作者:苏州老街
--  发布时间:2017/8/9 22:27:00
--  
老师,无法复制。



图片点击可在新窗口打开查看此主题相关图片如下:图像 2.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2017/8/9 22:29:00
--  

改一下

 

Dim pth As String = args(0)
Dim nms As List(of String) = args(1)
For Each fl As String In filesys.GetFiles(pth)
    nms.add(fl)
Next
For Each dr As String In FileSys.GetDirectories(pth)
    Functions.Execute("listfile",dr, nms)
Next


--  作者:苏州老街
--  发布时间:2017/8/9 22:49:00
--  
老师,双击事件没有用。


图片点击可在新窗口打开查看此主题相关图片如下:图像 3.png
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2017/8/9 22:51:00
--  
你得到nms之后你要怎么处理?你要怎么显示你就引用nms这个集合
--  作者:苏州老街
--  发布时间:2017/8/9 23:00:00
--  
老师,我最好文件的路径不显示直接显示采购凭证文件夹中的文件名称,谢谢老师帮我修改。


Dim nms As New List(of String)
Functions.Execute("listfile","I:\\百度云同步盘\\蓝峰管理\\Attachments\\采购凭证",nms)
[此贴子已经被作者于2017/8/9 23:01:18编辑过]

--  作者:有点甜
--  发布时间:2017/8/9 23:15:00
--  

你要显示到哪里怎么显示?

 

for each s As string in nms

    msgbox(s)

next


--  作者:苏州老街
--  发布时间:2017/8/10 8:49:00
--  
老师
    我搞不好,望老师帮忙。我要在窗口1、TextBox1显示递归数据。谢谢

--  作者:有点甜
--  发布时间:2017/8/10 9:07:00
--  

汗,你到现在连基本代码都不会写。

 

 

For Each s As String In nms
    Forms("窗口1").Controls("TextBox1").Text = String.join(vbcrlf, nms.ToArray)
Next