Can someone tell me why the variable i is not set in the below example? Are Class methods unable to modify the values of input variables?
In normal code module:
In a Class Module called SimpleClass:Code:Sub test_SimpleClass() Dim i As Long Dim s As SimpleClass Set s = New SimpleClass s.testx (i) Debug.Print "test_SimpleClass: i=" & i Set s = Nothing 'output: 'SimpleClass: constructor does nothing... 'SimpleClass: testx() a=345 'test_SimpleClass: i = 0 End Sub
Code:Option Explicit Private Const ID As String = "SimpleClass" Private Sub Class_Initialize() Debug.Print ID & ": constructor does nothing..." End Sub Public Sub testx(ByRef a As Long) a = 345 Debug.Print ID & ": testx() a=" & a End Sub



Reply With Quote
