Simple calculation problem with decimal value drivin me NUTS!!!!
-
im trying to multiply some numbers num1 is a normal integer,(1,2,3....) and num2 is a decimal number(0.23,1.00,3.00....) im having problems multiplying them, i've done it different ways sometimes i get a 0 in the total textbox or this error : Input String was not in a correct format. Can somebody help me out to rectify this problem.
if(Pharma.Rows.Count != 0) { string Tablet = (string) Pharma.Rows[0][0]; decimal num2 = Convert.ToDecimal(Tablet); MessageBox.Show(num2.ToString()); //0.23 int num3 = Convert.ToInt32(num2); int num1 = Int32.Parse(txtQuantity.Text); MessageBox.Show(num1.ToString()); //12 total = num1 * num3; decimal total1 = Convert.ToDecimal(total); MessageBox.Show(total.ToString()); //2.76 txtMedTotal.Text = total.ToString(); } else { MessageBox.Show("The Patient has yet to be processed","Information"); }
this code is givin me back a result of 0...when it should be 2.76 :doh: :doh: :doh: im three times confused now! -
im trying to multiply some numbers num1 is a normal integer,(1,2,3....) and num2 is a decimal number(0.23,1.00,3.00....) im having problems multiplying them, i've done it different ways sometimes i get a 0 in the total textbox or this error : Input String was not in a correct format. Can somebody help me out to rectify this problem.
if(Pharma.Rows.Count != 0) { string Tablet = (string) Pharma.Rows[0][0]; decimal num2 = Convert.ToDecimal(Tablet); MessageBox.Show(num2.ToString()); //0.23 int num3 = Convert.ToInt32(num2); int num1 = Int32.Parse(txtQuantity.Text); MessageBox.Show(num1.ToString()); //12 total = num1 * num3; decimal total1 = Convert.ToDecimal(total); MessageBox.Show(total.ToString()); //2.76 txtMedTotal.Text = total.ToString(); } else { MessageBox.Show("The Patient has yet to be processed","Information"); }
this code is givin me back a result of 0...when it should be 2.76 :doh: :doh: :doh: im three times confused now!