Results 1 to 2 of 2

Thread: [RESOLVED] Radio Buttons

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    61

    Resolved [RESOLVED] Radio Buttons

    I have a Groupbox called Sex then I have two radio buttons Male and Female. I also have a labelbox that I want the message "he" or "her" to go into. How would I get the "he" or "her" into the labelbox? I have variables called mMale and mFemale to use too. Thanx

    The labelBox's code right now is:

    lblAnswer.Text = Name & (" will earn ") & FormatCurrency(Total) & _
    " before retiring. And <Radio Button Message Needed> final salary will be " & FormatCurrency(Salary)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Radio Buttons

    Can I suggest using the more politically correct "gender" rather than "sex"? Also, I'd suggest not using FormatCurrency either:
    VB Code:
    1. Private Const MESSAGE As String = "{0} will earn {1} before retiring and {2} final salary will be {3}."
    2.  
    3. Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, _
    4.                                         ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
    5.     If Me.RadioButton1.Checked Then
    6.         Me.SetLabelText("his")
    7.     End If
    8. End Sub
    9.  
    10. Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, _
    11.                                         ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
    12.     If Me.RadioButton2.Checked Then
    13.         Me.SetLabelText("her")
    14.     End If
    15. End Sub
    16.  
    17. Private Sub SetLabelText(ByVal pronoun As String)
    18.     Me.Label1.Text = String.Format(MESSAGE, _
    19.                                    Name, _
    20.                                    Total.ToString("c"), _
    21.                                    pronoun, _
    22.                                    Salary.ToString("c"))
    23. End Sub
    Last edited by jmcilhinney; Aug 5th, 2006 at 09:51 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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