I'm trying to create a Sub
which will take a value and a Class
Property
and set the Property
for me.
In my Class
(Class1
) I have the following:
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
Then I am calling it using the following Sub
in Module1
Sub TestSetProperty()
Dim cl As New Class1
SetProperty "Test", cl.Value
Debug.Print "Value:", cl.Value
Debug.Print "Test:", cl.Test
End Sub
My SetProperty
Sub
contains
Sub SetProperty(v As String, ByRef prop)
prop = v
End Sub
Now I'd expect this to pass the property to the SetProperty
Sub
and set the value giving:
Value: Test
Test:
in the immediate window, however instead it returns
Value:
Test:
How can I make this work as expected?