【发布时间】:2020-08-12 05:18:21
【问题描述】:
我正在尝试创建一个Sub,它将接受一个值和一个Class Property,并为我设置Property。
在我的Class (Class1) 我有以下内容:
Option Explicit
Private vValue As String, vTest As String
Public Property Let Value(v As String)
vValue = v
End Property
Public Property Get Value() As String
Value = vValue
End Property
Public Property Let Test(v As String)
vTest = v
End Property
Public Property Get Test() As String
Test = vTest
End Property
然后我在Module1 中使用以下Sub 调用它
Sub TestSetProperty()
Dim cl As New Class1
SetProperty "Test", cl.Value
Debug.Print "Value:", cl.Value
Debug.Print "Test:", cl.Test
End Sub
我的SetProperty Sub 包含
Sub SetProperty(v As String, ByRef prop)
prop = v
End Sub
现在我希望这会将属性传递给 SetProperty Sub 并设置值:
Value: Test
Test:
在即时窗口中,但是它会返回
Value:
Test:
我怎样才能按预期进行这项工作?
【问题讨论】: