I have the ff. test code, could anyone point out what's happening here? Why is the passed Collection acting like it was passed ByRef?
VB Code:
Private Sub Command1_Click() Dim a As Long Dim CollectionTest As New Collection Dim StringTest As String CollectionTest.Add "Data1" CollectionTest.Add "Data2" ' Loop before passing to test contents For a = 1 To CollectionTest.Count MsgBox CollectionTest(a) Next ' Pass it as ByVal TestByVal CollectionTest ' The newly added value can be seen here For a = 1 To CollectionTest.Count MsgBox CollectionTest(a) Next StringTest = " Not passed yet " MsgBox StringTest TestAnotherByVal StringTest MsgBox StringTest End Sub Private Sub TestByVal(ByVal c As Collection) c.Add "Data3 - Created by ByVal" End Sub Private Sub TestAnotherByVal(ByVal s As String) s = s & " was passed ByVal " End Sub




Reply With Quote