Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have textbox1 and textbox 2
in textbox1 :
1,Vab,,,kV,0.014646,0.0,0.0,-2048,2047
2,Vbc,,,kV,0.014646,0.0,0.0,-2048,2047

in textbox2 :
3, 208, 697, -1021, 321, 30, 17, -67, 43, -7,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
4, 312, 726, -1014, 283, 31, 19, -65, 45, -5,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0
5, 416, 755, -1005, 247, 31, 21, -67, 42, -4,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0


My questions is :
1- how i can put every value in variable like array ( value in textbox1 and textbox2 )
2- how i can make some calculation in this value ( 0.014646 * 321 ) and put the result in new array ?
please if my questions not clear tell me to explain more
thank you .
Posted
Updated 26-May-15 21:27pm
v2

For the 1st question :
Here you can use the Method Split with the ',' as delimiter.
Split delivers you a String-Array with all elements from the source seperated.

For the 2nd question :
You must explain what the goal shall be - which Output do you Need ?
 
Share this answer
 
v2
Comments
Jerji Rani 27-May-15 3:54am    
Hello
for the first question it is enough :
using System;

public class SplitTest {
public static void Main() {

string words = "This is a list of words, with: a bit of punctuation" +
"\tand a tab character.";

string [] split = words.Split(new Char [] {' ', ',', '.', ':', '\t' });

foreach (string s in split) {

if (s.Trim() != "")
Console.WriteLine(s);
}
}
}
Jerji Rani 27-May-15 3:55am    
and for my secound one :
when i put all values in textbox1 and textbox2 in array
i wanna make * in this array
like :
value 4 in array 1 * value 2 in array 2
thank you .
Jerji Rani 27-May-15 5:02am    
I found code to read word by word :
int i = 0;
foreach (string line in File.ReadAllLines("path to text file"))
{
string[] parts = line.Split(',');
foreach (string part in parts)
{
MessageBox.Show(part);

}
i++; // For demo only
}
Start with either string.Split to break the strings, and use int.TryParse to convert the values you need; or use a CSV processor to read the strings: A Fast CSV Reader[^] is a good starting base.

From that, it's pretty simple to calculate values - but you would have to work out exactly what you want to do: we can't give you explicit instructions for generic questions.
I'd suggest you start by looking at the List<T> class to assemble your output results, though.
 
Share this answer
 

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