为什么这个简单的函数不会返回一个值?

我试图写一个函数返回一个集合,但似乎无法得到这个工作,所以我尝试了一些非常简单的东西。 我一定在做一些非常愚蠢的事情。

当我运行temp1,在下面的代码中,我期望看到这样的:

afunc value = 4 temp1 afunc = 4 

但我得到的是这样的:

 afunc value = 4 temp1 afunc = 0 

 Function aFunc() As Integer Dim theValue As Integer Dim retValue As Integer theValue = 4 Debug.Print "afunc value = " & theValue retValue = theValue End Function Sub temp1() Debug.Print "temp1 afunc = " & aFunc() End Sub 

我相信这是非常基本的东西,但我不知道它是什么。

aFunc()的末尾添加aFunc = theValue而不是retValue = theValue