'Visual Basic 2010 Collecties - Inleiding Object Oriented Programming Namespace Alternative1 Class Sentence Private m_Count As Integer Private m_Capacity As Integer = 16 Private m_Words(m_Capacity - 1) As String Public ReadOnly Property Count() As Integer Get Count = m_Count End Get End Property Default Public ReadOnly Property Item(ByVal index As Integer) As String Get Item = m_Words(index) End Get End Property Public Sub Add(ByVal word As String) m_Count += 1 If Count > m_Capacity Then m_Capacity *= 2 ReDim Preserve m_Words(m_Capacity - 1) End If m_Words(Count - 1) = word End Sub Public Function IndexOf(ByVal word As String) As Integer IndexOf = -1 If Count > 0 Then Dim found As Boolean Do IndexOf += 1 found = (Item(IndexOf) = word) Loop Until found OrElse IndexOf = Count - 1 If Not found Then IndexOf = -1 End If End Function Public Function Contains(ByVal word As String) As Boolean Contains = (IndexOf(word) <> -1) End Function End Class End Namespace 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.