3.c#winform Base Accumulator

Source: Internet
Author: User

Function: Cumulative calculation is realized.

Knowledge Points:

BOOL Int. TryParse (string s,out int result) (+1 overloads)

Converts the string form of a number to its equivalent 32-bit valid signed integer, a return value that indicates whether the operation succeeded.

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceAccumulator { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        Private voidButton1_Click (Objectsender, EventArgs e) {            stringS1 = TextBox1.Text;//text box One of the input contents is stored in the string S1            strings2 = TextBox2.Text;//text box One of the input contents is stored in the string S1            intI1,i2; /*BOOL Int.             TryParse (string s,out int result) (+1 overload) * Converts the string form of a number to its equivalent 32-bit valid signed integer, a return value that indicates whether the operation succeeded. */            if(int. TryParse (S1, outi1) = =false)//text box An input content string S1 converted to integer data i1{MessageBox.Show ("first number format Error!!! "); return; }            if(int. TryParse (S2, outi2) = =false)//text box An input content string S1 converted to integer data i2{MessageBox.Show ("Second number format Error!!! "); return; }            if(I1 >= I2)//Check for errors{MessageBox.Show ("The second number must be greater than the first number");//set a breakpoint in the wrong place to see the value of the relevant variable.                 return; }            intsum=0;  for(inti = I1; I <= i2; i++) {sum= Sum +i; } TextBox3.Text= convert.tostring (sum);//Assign the computed and assigned values to the text box three        }    }}

Program:

Software: Http://pan.baidu.com/s/1bnq256B

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.