-1

I haven't worked with VB in a long time, and I'm trying to add a membership object that includes a name, membership type, and additional options to a list when the user clicks a button. However as I step through my program in visual studio only the default data that is in my constructor is added to the list, not any of the data that i'm entering.

How can I get my data to successfully add to the list? Here's my code, any help would be appreciated

Dim memberList As New List(Of Membership)
Dim newMembership As New Membership

Here's my submit button

If MessageBox.Show("Do you wish to write this change to a file?",
       "Write to file", MessageBoxButtons.YesNo, MessageBoxIcon.Hand,
       MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
    memberList.Add(newMembership)
    MessageBox.Show("Added to list")

Default constructor

'default
Public Sub New()
    memberType = "Single"
    golf = False
    tennis = False
    Raquetball = False
    memberName = "Default"

Overloaded constructor

'overloaded
Public Sub New(ByVal mt As String, ByVal g As Boolean, ByVal t As Boolean, ByVal n As String, ByVal R As Boolean)
memberType = mt
golf = g
tennis = t
memberName = n
Raquetball = R
End Sub

My list when I click submit

golf        False       Boolean
memberName  "Default"   String
memberType  "Single"    String
Raquetball  False       Boolean
tennis      False       Boolean

Only the default values are showing, I'm confused as to where I set the properties and get the correct information submitted into a list

John
  • 151
  • 3
  • 12
  • Why you flag as c#? –  Dec 14 '16 at 02:20
  • This is identical to [your last question](http://stackoverflow.com/q/41132207/1070452) except the title. You could have just fixed the title. Same response: If you dont set any of the other properties (?, fields? - we dont know what they are) they will be the default. You arent showing that the other things are ever set. – Ňɏssa Pøngjǣrdenlarp Dec 14 '16 at 02:25
  • How would I set them, like getting/setting? @Plutonix – John Dec 14 '16 at 02:27
  • [Five Minute Intro to Classes and Lists](http://stackoverflow.com/a/34164458/1070452) You showed so little it is hard to be helpful - we dont know if it is a Class or Structure, Properties *or* Fields – Ňɏssa Pøngjǣrdenlarp Dec 14 '16 at 02:31

1 Answers1

0

Do this:

memberList.Add(newMembership("my memberType", true, false, "my member name",false))

Instead of this:

memberList.Add(newMembership)
Flávio Filho
  • 475
  • 4
  • 14