我有一个名为 Form1 的表单。在 Form1 中,我有以下代码 -
Dim details As clsDetails
Set details = getDetials(1) ' This fails. It doesn't assign a value.
getDetails 函数在一个单独的模块中声明如下 -
Public Function getDetials(detailNumber As Integer) As clsDetails
Dim details As clsDetails
Select Case detailNumber
Case "1"
Debug.Print "Inside case1"
Set details = getDetail1()
Debug.Print details.comment ' This prints correctly.
End Select
Set getDetails = details
End Function
但是,当我执行上述代码时,尽管调用了 getDetails 函数并在其中正确打印了详细信息,但 Form1 中的 details 变量并没有被设置。如何纠正这种情况?