0

Im stuck in this line. im new to c# and i just converted my code from vb.net to c#. after converting an unhandled error occured. i dont know what is the cause. some people say that Int32.Parse cause null exception but Convert.ToInt32 doesn't.

frmPointofSale pointofsale = new frmPointofSale();
this.btnOK.Enabled = true;
if (Convert.ToInt32(txtquantity.Text) < 1)
{
    this.btnOK.Enabled = false;
}
else if (Convert.ToInt32(txtquantity.Text) > Convert.ToInt32(pointofsale.dgvList.CurrentRow.Cells[8].Value.ToString()))
{
    btnOK.Enabled = false;
    MessageBox.Show("not enough quantity!");
    return;
}
TextBox3.Text = Convert.ToString(Convert.ToInt32(pointofsale.dgvList.CurrentRow.Cells[6].Value) * Convert.ToInt32(txtquantity.Text));

the error occurred in 'else if' statement. help me please. ty

Al Omar
  • 21
  • 1
  • 4
  • Run your code in Debug mode and when the exception show up, just look which variable is set to Null – MacakM Oct 22 '16 at 21:31
  • You create a new form but never do anything with it. Did you mean to show the form before trying to get data from its properties? – D Stanley Oct 22 '16 at 21:35
  • @DStanley im trying to to deduct the quantity ordered by a customer from another from. i just don't know why i have the error in "else if" statement what causing it and why – Al Omar Oct 22 '16 at 21:45

0 Answers0