|
-
May 3rd, 2013, 02:26 AM
#1
Thread Starter
Lively Member
person class
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
-
May 3rd, 2013, 02:29 AM
#2
Re: person class
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
-
May 3rd, 2013, 02:41 AM
#3
Thread Starter
Lively Member
Re: person class
can you give me a example
So I can see it what the code does
-
May 3rd, 2013, 02:46 AM
#4
Re: person class
What do you mean what does it do ? Isn't it obvious from the code I posted ?
-
May 3rd, 2013, 02:49 AM
#5
Thread Starter
Lively Member
Re: person class
no im learing vb
and I need a working example to see it how it works
-
May 3rd, 2013, 02:56 AM
#6
Re: person class
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.
-
May 3rd, 2013, 03:09 AM
#7
Thread Starter
Lively Member
Re: person class
but how can I give the status of the radio button to the classe
-
May 3rd, 2013, 03:15 AM
#8
Re: person class
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.
-
May 3rd, 2013, 03:27 AM
#9
Thread Starter
Lively Member
Re: person class
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.
Last edited by glda19; May 3rd, 2013 at 03:31 AM.
-
May 3rd, 2013, 03:44 AM
#10
Re: person class
Then set it by changing the Checked property of the RadioButton.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|