Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I Create 3 Text Boxs


1:Textbox 1 =15.0;

2:Textbox 2 = .10;


3:Textbox 3 = 15.0 * .10 like (Textbox 1 * Textbox 2)


How can do That to TextBox3
Posted
Comments
Magesh M N 9-Apr-15 7:29am    
what you have tried? What's the difficulty in this?.
krish2013 9-Apr-15 7:33am    
int i=Textbox.text;
int j=Textbox.text;
when textbox3 click event write a method for multipy the values
Magesh M N 9-Apr-15 7:38am    
Text property of TextBox is string you cannot directly convert it to int
krish2013 9-Apr-15 7:43am    
use convert.Toint32(Textbox1.Text) like that u can store text box values into variables
CHill60 9-Apr-15 7:49am    
Parse is better than Convert, TryParse is better again.

Quote:
when textbox3 click event write a method for multipy the values

1. Double-click on TextBox3 to get to the Click event handler code.
2. In that event capture the information in the other two textboxes - your code in your comment is close but you need to use something like double.TryParse[^] (NB the link is for int.TryParse but the principles are the same for all datatypes that support the TryParse method)
3. Do your calculation
4. Put the results into TextBox3 - hint you will need the ToString() method, and you might want to format the string[^]

Other hints:
- do you really want to use int? (as per your comment). Your sample data does not use integers. You might need to limit the size of the numbers entered. Or choose another data type.
 
Share this answer
 
v2
Comments
CPallini 9-Apr-15 7:50am    
5.
CHill60 9-Apr-15 7:51am    
Thank you! It's obviously homework so I was trying to guide rather than answer
Sascha Lefèvre 9-Apr-15 9:56am    
My 5. I support education-attempts ;)
Try this:
C#
decimal x, y;

bool isXValid = decimal.TryParse(Textbox1.Text, out x);

bool isYValid = decimal.TryParse(Textbox2.Text, out y);

if (isXValid && isYValid)
    Textbox3.Text = (x * y).ToString();
else
    Textbox3.Text = "Invalid input";

Learn more:
1. http://csharp.net-informations.com/gui/cs-textbox.htm[^]
2. https://msdn.microsoft.com/en-us/library/9zbda557%28v=vs.110%29.aspx[^]
 
Share this answer
 
v2

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