title: Making a Shift Key for a keyboard on a Windows Form
body: <p>I've recently started to learn both VB.net and C#. </p>
  
  <p>Anyway, I made a Windows Form application in VB.net that has a keyboard. </p>
  
  <p>To change the keys between upper and lower case, there is also a Shift Key, which works by looping through all of the controls on the form, and changing the case of the control's text based on the tabindex. </p>
  
  <p><strong>The VB.NET code:</strong></p>
  
  <pre><code>Private bShiftEngaged As Boolean
  
  Private Sub btnShift_Click(sender As Object, e As EventArgs) Handles btnShift.Click
      Dim ctrl As Control
  
      If bShiftEngaged = False Then
  
          For Each ctrl In Me.Controls
  
              If ctrl.TabIndex &gt;= 20 And ctrl.TabIndex &lt;= 45 Then
  
                  ctrl.Text = LCase(ctrl.Text)
  
              End If
  
          Next ctrl
  
      Else
  
          For Each ctrl In Me.Controls
  
              If ctrl.TabIndex &gt;= 20 And ctrl.TabIndex &lt;= 45 Then
  
                  ctrl.Text = UCase(ctrl.Text)
  
              End If
  
          Next ctrl
  
      End If
  
  End Sub
  </code></pre>
  
  <p>I have tried to replicate this in C#. The problem is that all of the controls change case. </p>
  
  <p><strong>C# Code:</strong> </p>
  
  <pre><code>    private void btnShift_Click(object sender, EventArgs e)
          {
          if (bShiftEngaged == false)
              {
              foreach (Control ctrl in this.Controls)
                  {
                  if (ctrl.TabIndex &gt;= 20 &amp;&amp; ctrl.TabIndex &lt;= 45) ;
                      {
                     ctrl.Text = ctrl.Text.ToLower();
                      }
                  }
               }
          else
              {
              foreach (Control ctrl in this.Controls)
                  {
                  if (ctrl.TabIndex &gt;= 20 &amp;&amp; ctrl.TabIndex &lt;= 45) ;
                      {
                      ctrl.Text = ctrl.Text.ToUpper();
                      }
                  }
              }
          }
  </code></pre>
  
  <p>I would appreciate help in changing the code so only the controls with a tabindex between <code>20</code> and <code>45</code> are affected.</p>