0
我想写一个函数返回一个集合,但似乎无法让它工作,所以我尝试了一些非常简单的东西。我一定在做一些非常愚蠢的事情。为什么这个简单的函数不会返回值?
当我运行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'设置为函数中的一个值,所以它返回0.我想你想'aFunc = theValue'。 – findwindow
好的,谢谢...从来没有在文档中看到过......似乎返回的值将是最后执行的语句。 – nPn
这是一个可怕的文档,然后在VBA中使用XD,函数返回自身。 – findwindow