C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Functionality of a backspace as in a calculator


Posted Date: 30 Oct 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: MounikaMember Level: Bronze    
Rating: 1 out of 5Points: 10



This piece of code is used to achieve the functionality of a backspace as in a calculator. I wrote this code in a sample and wanted to share as it is sometimes of immense use in some calculations.


textBox1 is the textbox on which we should use backspace funtionality.
ar is an arrarlist.

First declare
Arrayalist ar = new ArrayList();

In backspace button click add this piece of code

if (textBox1.Text != "0.")
{

if (ar.Count>1)
{
ar.RemoveAt(ar.Count - 1);

string strText = "";
for (int i = 0; i < ar.Count; i++)
{
strText = strText + ar[i].ToString();
}
textBox1.Text = strText;
return;
}
else
{
ar.Clear();
textBox1.Text= "0.";
}
return;

}
else
{
ar.Clear();
textBox1.Text = "0.";
return;
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Backspace  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Open File/Exe
Previous Resource: Demand FileIOPermissionAccess.AllAccess
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use