Writing Code for Radio Buttons, If certain text is in textbox

  • Thread starter Thread starter Gary Simpson
  • Start date Start date
G

Gary Simpson

Guest
Hi Good People

I have a form with 3 Radio Buttons that I have re-name (RBMR, RBMRS, RBMISS)

I also have a Textbox named (TxtGender)

When I click BindingSourceNavigator. Move next Item Or Previous Item and the Text changes in the textbox (TxtGender) And what ever value is in the Textbox (TxtGender) Could only be (Mr, Mrs, Miss)

I want to change which Radio Button Is checked to the corresponding text in Textbox (TxtGender)

I have tried Select case And other ways But All I get is all three Radio flashing and after a while An error. the code I have tried...


Private Sub TxtGender_TextChanged(sender As Object, e As EventArgs) Handles TxtGender.TextChanged
'I tried this ----------------------------------------------------
Dim Text As String = (TxtGender.Text)

Select Case Text
Case "Mr"
RbMR.Checked = True
Case "Mrs"
RbMRS.Checked = True
Case "Miss"
RbMISS.Checked = True
Case ""
Dim radioButton = RbMR,
Dim RadioButton = RbMRS,
Dim radioButton = RbMISS,
.Checked = False
End Select

'I Tried this as well --------------------------------------------

If TxtGender.Text = "Mr".ToString Then
RbMR.Checked = CheckState.Checked
RbMRS.Checked = CheckState.Unchecked
RbMISS.Checked = CheckState.Unchecked

ElseIf TxtGender.Text = "Mrs".ToString Then
RbMR.Checked = CheckState.Unchecked
RbMRS.Checked = CheckState.Checked
RbMISS.Checked = CheckState.Unchecked


ElseIf TxtGender.Text = "Miss".ToString Then
RbMR.Checked = CheckState.Unchecked
RbMRS.Checked = CheckState.Unchecked
RbMISS.Checked = CheckState.Checked
Else

RbMR.Checked = CheckState.Unchecked
RbMRS.Checked = CheckState.Unchecked
RbMISS.Checked = CheckState.Unchecked
End If
End Sub

Kind Regards

Gary


Gary Simpson

Continue reading...
 
Back
Top