VBA Function的返回值能不能是Dictionary
本帖最后由 zhengzunyao 于 2013-01-22 10:54:35 编辑
Function SigTop5(ByVal SessionCode) As Dictionary
Set SigTop5 = New Dictionary
'..........
End Function
Sub a()
Dim SessionCode
Dim Sig_Top5 As Dictionary
Set Sig_Top5 = New Dictionary
SessionCode = ...... 'SessionCode在这里赋值
Sig_Top5 = SigTop5(SessionCode)
End Sub
Function SigTop5(ByVal SessionCode) As Object
Set SigTop5 = CreateObject("Scripting.Dictionary")
SigTop5.Add "A", 300
SigTop5.Add "B", 400
SigTop5.Add "C", 500
End Function
Sub a()
Dim SessionCode
Dim Sig_Top6
Set Sig_Top6 = SigTop5(SessionCode)
k = Sig_Top6.keys
v = Sig_Top6.Items
For i = 0 To Sig_Top6.Count - 1
key = k(i)
Value = v(i)
Debug.Print key & Value
Next
End Sub