Hi guys,
Just starting with VBA objects and I got stuck at the very beginning.
I created "Student" class with code:
Public FirstName As String
Public LastName As String
And then in the module:
Sub TestStudent()
Dim oStudent As New Student
Dim Students As New Collection
With oStudent
.FirstName = "Bart"
.LastName = "Simmons"
End With
Students.Add oStudent, "a"
With oStudent
.FirstName = "Lisa"
.LastName = "Simmons"
End With
Students.Add oStudent, "b"
End Sub
as a result I expected:
Students.Item("a").FirstName
to have value "Bart"
unfortunately values of all items in students collection changes each time when change oStudent object, and returns the last added value.
Where am I wrong ?
Gonzul
Bookmarks