Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleCreate a class with a parameterized property
DescriptionThis example shows how to create a class with a parameterized property in Visual Basic 6.
Keywordsclass, property, parameter
CategoriesMiscellany, Software Engineering
 
The class's Property Get and Property Let procedures take an extra parameter.
 
Private m_Messages() As String
Private m_NumMessages As Integer

Public Property Let Message(ByVal index As Integer, ByVal _
    new_message As String)
    If index < 1 Then
        Err.Raise 380, "LabelList.Caption", _
            "Caption index must be greater than zero."
    End If

    ' Make room if necessary.
    If index > m_NumMessages Then
        m_NumMessages = index
        ReDim Preserve m_Messages(1 To m_NumMessages)
    End If

    m_Messages(index) = new_message
End Property

Public Property Get Message(ByVal index As Integer) As _
    String
    If index < 0 Or index > m_NumMessages Then
        Err.Raise 380, "LabelList.Caption", _
            "Caption index must be between zero and " & _
            m_NumMessages & "."
    End If

    Message = m_Messages(index)
End Property
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated