I have a class, it looks like this(ill keep it simple):
now i create instance of this like so:Code:Public Class Person Private m_Name as String Public Property Name() As String Get Name = m_Name End Get Set(ByVal Value As String) m_Name = Value End Set End Property End Class
But what i want to do is set his name right away when i create the instance like this:Code:Dim OldMan As New Person
What do i have to add to my class to make this possible? I thought i could add a Sub New to my class like this to make it possible but it does not seem to work:Code:Dim OldMan As New Person("Mr. Smith")
but i just get an error saying "Argument not specified for parameter n"Code:Sub New(ByVal n as String) m_Name = n End Sub
Can someone help me out please, i just need to know how to set a property of a class right when i instance it.




Reply With Quote