Object data is being overwritten

I am trying to create a object that is self contained with methods, properties and functions.  My scenario is simple.  I have created one object called a Template that contains a property called name.  I have created a second object called Field that has several properties.  I would like to be able to add multiple fields to the template object.  Then I can use the template object in other programs.  

My problem is that the properties of the Field object are getting overwritten each time I call it in the AddField function.  I am pasting the code below for you to review.   What am I doing wrong?
Thanks,

Public Class PTITemplate
 Private Shared strName As String
 Private Shared aFields As ArrayList
 Public Shared Property TemplateName() As String
   Get
     TemplateName = strName
   End Get
   Set(ByVal Value As String)
     If Value <> "" Then strName = Value
   End Set
 End Property

 Public Shared Function AddField(ByVal FieldName As String, ByVal FieldType As Int16) As Boolean
  Dim addPTIField2 As PTIField
  addPTIField2 = New PTIField
  addPTIField2.Name = FieldName
  addPTIField2.Type = FieldType
  aFields.Add(addPTIField2)

  Dim objElement As PTIField
  For Each obj As Object In aFields
    objElement = CType(obj, PTIField)
    Console.WriteLine(objElement.Name)
    Console.WriteLine(CStr(objElement.Type))
  Next
  addPTIField2 = Nothing
 End Function
End Class

Public Class PTIField
 Private Shared sName As String
 Private Shared iType As Int16
 Sub New()

 End Sub
 Sub New(ByVal fName As String)
   sName = fName
 End Sub
 Sub New(ByVal fName As String, ByVal fType As Int16)
   sName = fName
   iType = fType
 End Sub
 Public Shared Property Name() As String
   Get
     Name = sName
   End Get
   Set(ByVal Value As String)
     sName = Value
   End Set
 End Property
 Public Shared Property Type() As Int16
   Get
     Type = iType
   End Get
   Set(ByVal Value As Int16)
     iType = Value
   End Set
 End Property

End Class
WhahAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Remove the Shared keyword EVERYWHERE you see it...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WhahAuthor Commented:
Thank you very much for that quick and accurate response.  I didn't know that it couldn't be a shared class.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
The Shared keyword indicates that something should be shared across ALL instances of a class.  So when you change the value in one instance, all instances also see that change.

When you remove the shared keyword then each instance keeps its OWN copy of the values.

=)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.