Divide the values in textboxes and produce the value in a 3rd textbox
<p>I am trying to Divide two values that are in 2 different textboxes and have the result show up in a 3rd textbox. Here is the code I have so far:</p>

<pre><code>private void Divide()
{
  int val1, val2;
  if (!string.IsNullOrEmpty(mergeSortTime.Text) &amp;&amp; !string.IsNullOrEmpty(selectionSortTime.Text))
  {
    int.TryParse(mergeSortTime.Text, out val1);
    int.TryParse(selectionSortTime.Text, out val2);
    resetTimeDisplay.Text = (val1 / val2).ToString();
  }
}
</code></pre>

<p>and I call the Method here:</p>

<pre><code>private void selectionSortButton_Click(object sender, EventArgs e)
{

  selectionSortButton.Enabled = false;
  button1.Location = resetButton.Location;
  button1.Visible = true;
  InitializeForm();
  sw.Start();
  bgWorker.RunWorkerAsync();
  while (bgWorker.IsBusy)
    Application.DoEvents();
  idList.SelectionSort();
  if (!bgWorkCancelled)
    DisplayIDList(displayDGV);
  sw.Stop();
  TimeSpan ts = sw.Elapsed;
  string elapsedTime = String.Format("{0:0}" + "." + "{1:0}",ts.Seconds, ts.Milliseconds);
  selectionSortTime.Text = elapsedTime;
  mergeSortButton.Enabled = false;
  quickSortButton.Enabled = false;
  resetButton.Location = button1.Location;
  button1.Visible = false;
  resetButton.Visible = true;
  Divide();
}
</code></pre>

<p>how it works right now is I input a number into a totally separate textbox and generate a list of unordered values. I then have 2 buttons that use 2 different ways of sorting and next to them I have a display showing how long it took to sort the values. the 2 display values I need to divide. It's giving me an error that says: "Attempted to divide by zero", I've tried debugging the code and saw that val1 and val2 both have a value of 0, so the error is obviously correct? but <code>mergeSortTime.Text</code> and <code>selectionSortTime.Text</code> both have the correct values as well. </p>

<p>Anyone mind sharing some insight?</p>

<p>Thank You!</p>