multiplying number in a textbox to the quantity value

I have this TextBox named Amount and a NumericUpDown named quantity1. How do i multiply the TextBox which is double to the value of the NumericUpdown?

double amt;
double ans;

amt = Double.Parse(Amount.Text);
tot = Double.Parse(Total.Text);

//I have another textbox called total.
ans = amt * (quantity1.Value) //how do i do this? it has error.

Upvotes: 2

Views: 2447

Answers (2)

Aritra Chakraborty
Aritra Chakraborty

Reputation: 12542

double amt = Convert.ToDouble(Amount.Text);
double qnt = Convert.ToDouble(quantity.Value);
double ans = amt * qnt;
Total.Text = ans.ToString();

Upvotes: 1

Ramakrishna.p
Ramakrishna.p

Reputation: 1201

convert the value of quantity1.Value to double AND after apply multiplication and then convert the result to string and assign to textbox it may resolve your problem

Upvotes: 1

Related Questions