title: How to set value of progress bar
body: <p>I have written a user control using C# Winforms. In the user control, I have three textboxes:</p>
  
  <ul>
  <li>txtStartNumber - input is of type: int.</li>
  <li>txtEndNumber  - input is of type: int. </li>
  <li>txtQuantity - iput is of type: int. (value = txtEndNumber - txtStartNumber)</li>
  </ul>
  
  <p>The progress bar denotes the no. of records added to the database and its total range is set to be equal to txtQuantity.</p>
  
  <p>When one or more records are duplicate, the progress bar is stopped.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How to set the initial value of the progress bar?</li>
  <li>How to manage the progress shown by progress bar?</li>
  </ol>
  
  <p>How I save it to the database:</p>
  
  <pre><code>for (long i = from; i &lt; to; i++)
  {
      for (int j = 0; j &lt; (to - from); j++)
      {
          arrCardNum[j] = from + j;
          string r = arrCardNum[j].ToString();
          try
          {
              sp.SaveCards(r, 2, card_Type_ID, SaveDate, 2);
              progressBar1.Value = j;
          }
      }
  }
  </code></pre>