Home > Net >  C # how to make the same number in the textbox
C # how to make the same number in the textbox

Time:01-05

Use notepad to import the textbox value, then want to add up these Numbers, have bosses will

CodePudding user response:

in the excel spreadsheet, computing is, the boss

CodePudding user response:

Just use Excel, function is very powerful,

CodePudding user response:

 
Var text="111 \ r \ n222 \ r \ n333 \ r \ n";
Var arr=text. The Split (" \ r \ n ". ToCharArray ());
var sum=0;
The foreach (var item in arr)
{
The sum +=item. ToInt ();
}


Probably is this meaning, the details, to run if you have any question to adjust again

CodePudding user response:

To convert a string to integer and add it,

CodePudding user response:

I want to directly in the window display

CodePudding user response:

Can be calculated in the form

CodePudding user response:

to use EXCEL to go ~ unless you want to be lazy, the design of a process is necessary, you can line in TXT read, turn the type, added together, it is not necessary to import the textbox

CodePudding user response:

Premise is no interval of empty lines
Private void button1_Click (object sender, EventArgs e)
{
if (! String. IsNullOrEmpty (textBox1. Text))
{
Var text=textBox1. Text. Replace (" \ r \ n ", "+");
If (text [text Length - 1]=='+') text +="0";
TextBox1. AppendText (" \ r \ n total: "+ new DataTable (.) Compute (text, null). The ToString ());
}
}
  •  Tags:  
  • C#
  • Related