title: How to simplify this visual basic code about radio buttons and numberupdown controls
body: <p>I have a group with a NumberUpDown control, 0-10 by 1 and 11 radio buttons (equal to the range of the NumberUpDown control). I have been able to write code in the events of the controls such that when a radio button is checked the value of the NumberUpDown changes to that of the radio button checked and when the NumberUpDown value is changed, the correct radio button is checked.</p>
  
  <p>There are users that want to use a stylus to click on the radio buttons and there are those that want to use the keyboard to enter the values.</p>
  
  <p>Below is the code I wrote. The LONG if/then/else should be able to be written a different way. It would seem that RadioButtonArray (VB6) would solve my problem, but that's old school. I'm just not familiar with VB.NET enough to figure out how. I'm using Visual Studio 2010.</p>
  
  <p><code>PainAcceptable</code> is the NumberUpDown control. <code>PainAx</Code> are the individual radio buttons.</p>
  
  <pre><code>Private Sub PainAcceptable_ValueChanged(sender As System.Object, e As System.EventArgs) Handles PainAcceptable.ValueChanged
      If PainAcceptable.Value = 0 Then
          PainA0.Checked = True
      ElseIf PainAcceptable.Value = 1 Then
          PainA1.Checked = True
      ElseIf PainAcceptable.Value = 2 Then
          PainA2.Checked = True
      ElseIf PainAcceptable.Value = 3 Then
          PainA3.Checked = True
      ElseIf PainAcceptable.Value = 4 Then
          PainA4.Checked = True
      ElseIf PainAcceptable.Value = 5 Then
          PainA5.Checked = True
      ElseIf PainAcceptable.Value = 6 Then
          PainA6.Checked = True
      ElseIf PainAcceptable.Value = 7 Then
          PainA7.Checked = True
      ElseIf PainAcceptable.Value = 8 Then
          PainA8.Checked = True
      ElseIf PainAcceptable.Value = 9 Then
          PainA9.Checked = True
      ElseIf PainAcceptable.Value = 10 Then
          PainA10.Checked = True
      End If
  End Sub
  ' When radio button PainA1 is changed, PainAcceptable is set to the value 1
  Private Sub PainA1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles PainA1.CheckedChanged
      If PainA1.Checked Then
          PainAcceptable.Value = 1
      End If
  End Sub
  </code></pre>