hi in this code im trying to convert a double from a label into the variable but im coming up with the exception
“Unable to cast object of type ‘System.Windows.Forms.Label’ to type
‘System.IConvertible’.”
on the "convert.toDouble(lblPricekey);" area and I’m not sure why.
private void btnAddtoTotal_Click(object sender, EventArgs e)
{
double numPadTotal;
numPadTotal = Convert.ToDouble(lblPricekey.Text);
double finalTotal = total + numPadTotal;
txtTotal.Text = finalTotal.ToString();
}
You are converting
Labeltodouble. You should convertLabel.Text.