Results 1 to 6 of 6

Thread: A question about classes [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Location
    Kirkland, WA
    Posts
    7

    A question about classes [RESOLVED]

    I have a class, it looks like this(ill keep it simple):

    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
    now i create instance of this like so:

    Code:
         Dim OldMan As New Person
    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("Mr. Smith")
    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:
         Sub New(ByVal n as String)
              m_Name = n
         End Sub
    but i just get an error saying "Argument not specified for parameter n"

    Can someone help me out please, i just need to know how to set a property of a class right when i instance it.
    Last edited by ZoomyX; Jan 16th, 2004 at 06:21 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width