Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
double toal, a = Convert.ToDouble(TextBox6.Text), b = Convert.ToDouble(TextBox7.Text), c = Convert.ToDouble(TextBox8.Text);
       toal = (a + b + c );
        Label2.Text = toal.ToString();
whenever am executing this program am getting Input string was not in a correct format. how can i solve this help me from this
Posted
Updated 29-Dec-11 23:40pm
v2
Comments
anushripatil 30-Dec-11 5:42am    
please explain more, that where exactly are u getting that error & what are b & c ??? .

Most likely yuo have illegal characters in your textbox.

Instead of directly converting the text to a number, use Double.TryParse[^]. It helps you to see the problems without generating an exception.
 
Share this answer
 
Comments
Rajesh Anuhya 30-Dec-11 5:43am    
+5.., Proposed as Answer.
Wendelius 30-Dec-11 6:07am    
Thank you Rajesh.
Use double.TryParse instead - the problem is that your user's inputs are not valid string representations of numeric values, so you get an error. TryParse gives you a good/bad signal instead of throwing an exception, allowing you to report the problem to your user so he can fix it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900