Private Sub Command1_Click()
For i = 1 To UBound(allday(2004))
List1.AddItem allday(2004)(i)
Next
End Sub
Function allday(ByVal theyear As Long)
Dim temp() As String, i As Long, num As Long
num = DateDiff("d", DateSerial(theyear, 1, 1), DateSerial(theyear + 1, 1, 1))
ReDim temp(1 To num)
For i = 1 To num
temp(i) = DateSerial(theyear, 1, i)
Next
allday = temp
End Function
1 返回数组
'返回数组的例子
Private Sub Command1_Click()
Dim I As Integer
Dim str2() As String
str2 = 返回数组
For I = 0 To UBound(str2) - 1
Debug.Print str2(I)
Next
End Sub
Function 返回数组() As String()
Dim str1() As String
str1 = Split("a,b,c,d,e", ",")
返回数组 = str1
End Function
2 返回自定义类型数据
Private Type MyRecord
name As String
address As String
End Type
Private Sub Command1_Click()
MsgBox ReturnInfo.name
MsgBox ReturnInfo.address
End Sub
Private Function ReturnInfo() As MyRecord
ReturnInfo.name = "呵呵"
ReturnInfo.address = "广州"
End Function
谢谢大家!
我就是想返回数组,现已经明白了!
还想问个问题:
redim 数组(i) 时是否有什么函数可以返回数组元素的个数? 还是要 for 两遍才能确定?或者能否同时返回数组(i)和i两人值呢?水平有限见笑了!
晚点结贴,再次谢谢以上热心的朋友!
如:
for each objs as object.sub
i=i+1
next
redim 数组(i)
for each objs as object.sub
数组(j)=objs
next