Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
Hi,

I have a masked textbox in my program to insert money.
How to sum this masked textbox to another textBox? I want sum to the money where the user added it.
Posted
Updated 26-Nov-10 22:34pm
v2

convert your text value of text box to decimal
 
Share this answer
 
Comments
raheleh_es 27-Nov-10 5:58am    
plz give me exam
dhirennaik 28-Nov-10 4:08am    
Dim nValue as Decimal
nValue = CDec(YourTextBox1.Text) + CDec(YourTextBox2.Text)
here is your answer in nValue
Change the Mask property - see here[^].
 
Share this answer
 
C#
//You first convert into int or long. Well You are saying its money so better use float or double data types.
//here is the code. I prefer double.
if (maskedTextBox1.Text != null)//Cheak if textbox has value or not. If value present then convert it to double.
{
  double money=Convert.ToDouble(maskedTextBox1.Text)+Convert.ToDouble(maskedTextBox1.Text);//converted into double data type. money is variable.
textBox1.Text=money.ToString();//.ToString() method is available for any varable, any function, any data type to convert it into string for displating in textbox or some thing.
}

Convert the two values and add them thats it. Try it it works.
WHy double and float. Beacause money is in decimal format. for example 100.80 $. To store point value we have an data type called double. So use it. I have one more suggesion. While you declare any decimal value in program declare as
float decimal=10.9f;

Enjoy :laugh: :-D .
 
Share this answer
 
v5
Comments
raheleh_es 28-Nov-10 23:34pm    
Thank'ssssssssssss
raheleh_es 28-Nov-10 23:42pm    
my masket have this mask .../.../...

and I want to sum this mony?

Do you know??

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