Input string was not in a correct format.
How to multiply or add two textboxes double typed values?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 13, 2015, 1:31 AM EST
Hi,
Textbox always contains string value so you have to cast this value to double.
try this....
double number;
double number1;
Double.TryParse(Textbox1.Text, out number);
Double.TryParse(Textbox2.Text, out number1);
double sum = number+number1;
hope this will help you.
Dawood AbbasRank #6,413 · 267 reputationPosted Feb 13, 2015, 1:38 AM EST
like below
double does not contain a definition for 'Text' and no extension methode 'Text accepting a first argument of type 'double' could be found (are you missing a using directive or and assemble reference?)
I tried alredy and also like below
double amount =convert.ToDouble(txtamount.Text);
here also showing same above error message.
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 13, 2015, 1:44 AM EST
Hi,
here Textbox1.text and textbox2.text is your textbox value.
also double.tryparse function return 0 if function is fail to convert value to double.
Please refer below link for more information.
https://msdn.microsoft.com/en-us/library/3s27fasw(v=vs.110).aspx
can you please share textbox value?
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 13, 2015, 1:44 AM EST
use convert in uppercase with c
Dawood AbbasRank #6,413 · 267 reputationPosted Feb 15, 2015, 7:33 PM EST
Package Name:
ddlPackName
No. of Extra Connection:
txtNoConn
Charges per Connection(If any):
txtChargeConn
Installation Charges:
txtInstlChrge
Discount (if any):
txtDisc
Amount to Pay:
txtAmntToPay
Paying Amount:
txtPayAmnt
Balance:
txtBlnc
How to get final result1 (txtAmntToPay.text)? and final result2 (txtBlnc)
1).if I select 'ddlPackName' then its price display in 'txtAmntToPay.text'
2).if I enter 'txtNoConn' and 'txtChargeConn' then multiple this both and add with 'ddlpackname' then display in 'txtamnttoPay'
if I not select 'ddlpackname' then display multiplied values.
3).like this all textboxes values add with 'txtPayAmnt' and subtract 'txtDisc'
Dawood AbbasRank #6,413 · 267 reputationPosted Feb 15, 2015, 7:38 PM EST
public void regCustCalculation()
Dawood AbbasRank #6,413 · 267 reputationPosted Feb 15, 2015, 7:39 PM EST