You are declaring the family variable inside the Form_load event/sub which means it is not valid outside of that sub. So any reference to it that is after the End Sub will fail. You need to declare it in the form declarations not in an event for it to be in the right scope.
VB Code:
'inside form1 but not in any event Dim family As New Collection() Public Sub Form1_Load.... 'nothing needed here End Sub Private Sub Button1_Click... family.Add("Tom") End Sub




Reply With Quote