hi
I have a person class
Where I store the name, the city, how many sons and daughter he have.
But I have a groupbox with 3 radio buttons not married , married and lives alone.
How can I store then in the class person
Printable View
hi
I have a person class
Where I store the name, the city, how many sons and daughter he have.
But I have a groupbox with 3 radio buttons not married , married and lives alone.
How can I store then in the class person
You can use an enum:-
vbnet Code:
Public Enum PersonStatus Married NotMarried LivesAlone End Enum Public Class Person ' Other properties..... Public Property Status As PersonStatus End Class
can you give me a example
So I can see it what the code does
What do you mean what does it do ? Isn't it obvious from the code I posted ?
no im learing vb
and I need a working example to see it how it works
Its a simple property just like any other. You set the Status property just like you set any other property. The VS IDE intellisense would automatically give you the enum options when you try to set the property in code.
but how can I give the status of the radio button to the classe
Here is an example:-
vbnet Code:
' Dim p As New Person If rbLivesAlone.Checked Then p.Status = PersonStatus.LivesAlone If rbMarried.Checked Then p.Status = PersonStatus.Married If rbNotMarried.Checked Then p.Status = PersonStatus.NotMarried
rbLivesAlone, rbMarried and rbNotMarried are your radio buttons.
so I have to put the name in a listbox
When I have set married an I click on the item in the listbox the radiobutton married must selected.
Then set it by changing the Checked property of the RadioButton.