Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
text box1 =2
text box2 =5

the result for text box 3 is;
textbox3 = (text box1*text box2) = 10


how can put $ with 10
like
textbox3 = 10$
Posted
Comments
DamithSL 22-May-15 6:13am    
update the question with your code, you can try as below
textbox3.Text = calculatedValue.ToString()+"$";
Tomas Takac 22-May-15 6:15am    
What about appending the $ sign? Really, what have you tried? Where are you stuck?
Member 11280947 22-May-15 6:51am    
Thank You

Well, since currency formatters in C# will place the "$" symbol at the beginning, you will have to append the "$" as :

TextBox3.Text = (x * y).ToString(); + "$"


where x and y are the numeric values fetched from textbox1 and textbox2
 
Share this answer
 
You have to convert the values from the Textbox input - which is a string - to a number.
The best way to do that is to use TryParse:
C#
int x;
if (!int.TryParse(Textbox1.Text, out x))
   {
   // Complain about user input
   return;
   }
// x now holds the value.
Repeat that for the other value into y and then do your operation.
Finally, show the result as a string:
C#
TextBox3.Text = (x * y).ToString();
 
Share this answer
 
Comments
Member 11280947 22-May-15 6:51am    
Thank You
OriginalGriff 22-May-15 7:05am    
You're welcome!

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