欢迎光临

木子屋

标题: VB6.0函数返回数组示例

作者: dnawo

日期: 2009-09-30 11:39 AM

分类: Win编程

内容: 复制内容到剪贴板 程序代码'函数返回数组示例
Function GetFiles(path As String) As String()
Dim oFso As Scripting.FileSystemObject
Dim oFolder As Scripting.Folder
Dim oFile As Scripting.File
Dim i As Integer
Dim list() As String '1.声明一个临时数组

Set oFso = New Scripting.FileSystemObject
Set oFolder = oFso.GetFolder(path)
ReDim Preserve list(oFolder.Files.Count - 1)
For Each oFile In oFolder.Files
list(i) = oFile.path
i = i + 1
Next
GetFiles = list '2.临时数组赋值给函数名

Set oFile = Nothing
Set oFolder = Nothing
Set oFso = Nothing
End Function
调用示例：
复制内容到剪贴板 程序代码Dim a() As String
a = GetFiles("F:\0598")
For i = 0 To UBound(a)
Text1.Text = Text1.Text & a(i) & vbCrLf
Next

+ 查看当前日志评论 (0)

登录

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.453 ms

返回

标题: VB6.0函数返回数组示例

你没有权限发表评论

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.453 ms

返回

暂无评论

返回

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.484 ms

返回