I'm having trouble following your business logic. You start out by declaring a variable
a
as a double. Then you test the
txtItemQty
value to see if it is blank, and if it is, you immediately recast the type to
float
and assign it the value of 0.00. Later you clearly indicate that you mean the variable
m
to hold the value of
txtItemQty
as a
double
; why not be consistent?
Let's do this another way:
if (txtItemQty.Text != "")
{
double m = double.Parse(txtItemQty.Text);
double n = double.Parse(txtPrice.Text);
double k = m*n;
MessageBox.Show("Your cost is " & k.ToString());
}
else
{
MessageBox.Show("Please enter a quantity and retry.");
}