VB6.0函数返回数组示例 - 木子屋 和另外 4 个页面 - 用户配置 1

VB6.0函数返回数组示例编辑:dnawo 日期:2009-09-30字体大小: 小 中 大

复制内容到剪贴板程序代码'函数返回数组示例Function GetFiles(path As String) As String()Dim oFso As Scripting.FileSystemObjectDim oFolder As Scripting.FolderDim oFile As Scripting.FileDim i As IntegerDim list() As String '1.声明一个临时数组Set oFso = New Scripting.FileSystemObjectSet oFolder = oFso.GetFolder(path)ReDim Preserve list(oFolder.Files.Count - 1)For Each oFile In oFolder.Fileslist(i) = oFile.pathi = i + 1NextGetFiles = list '2.临时数组赋值给函数名Set oFile = NothingSet oFolder = NothingSet oFso = NothingEnd Function调用示例:复制内容到剪贴板程序代码Dim a() As Stringa = GetFiles("F:\0598")For i = 0 To UBound(a)Text1.Text = Text1.Text & a(i) & vbCrLfNext

(0)

相关推荐