TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
631
1.3k
217.4k
Increment manually...
Jul 8 2014 11:04 AM
Hello!
I have on my form: two button (one for "Add" and other one for "Minus"), one label that will have always the number "1" and one textbox that will have the number 0 in load the form (its can be changed only when I click on one of the button "add" or "minus").
I wrote this code to increment manually step by step one number. For example: if in my textbox content 0 when I click my button its will add "1". When you click again its will add "1" (in textbox will appear "2"). Means 1 plus 1 plus 1 plus 1 plus 1 plus 1 etc.
Then when I click to the minus button its make substration. Until there every think it's ok. But what I need now: I want when I click on the minus button its cannot do this "-1". The only CONDITION is its cannot descrease number (the limit it's "0" never negative number):
This increase and working well:
private void btnplus_consStocks_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(lblIncrement.Text))
{
return;
}
double increment1;
double increment2;
double resultincrement;
increment1 = Convert.ToDouble(lblIncrement.Text);
increment2 = Convert.ToDouble(stockLimitadoUpDown1.Text);
resultincrement = increment1 + increment2;
stockLimitadoUpDown1.Text = resultincrement.ToString();
}
But this its decrease well but when its arrive to "0" when you click again its show "-1" as I already explain:
private void btnmenos_consStocks_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(lblIncrement.Text))
{
return;
}
double increment1;
double increment2;
double resultincrement;
increment1 = Convert.ToDouble(lblIncrement.Text);
increment2 = Convert.ToDouble(stockLimitadoUpDown1.Text);
resultincrement = increment2 - increment1;
stockLimitadoUpDown1.Text = resultincrement.ToString();
}
Reply
Answers (
2
)
mvc webgrid actionlink popup
How to write a Nunit test for this kind of method()