Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-04-24 : 14:44:31
|
Hello,I have the following while loop. Am trying to test for some values from a split function using c#However, I dont get any values back in the loop. Whats wrong herethanksstring[] csvParts = TextBox1.Text.Split(',');int length = csvParts.Length;int i = 0;do{ i++; Label1.Text = length.ToString() }while (i < length); |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-04-24 : 15:08:27
|
????You are just setting the label's Text property to the length of the array returned from the split over and over.If you want to reference element i in the array, it is Label1.Text = csvParts[i];But even then, the label will only contain the value of the last element in the array because you keep overwriting the Text property over and over.What exactly are you trying to do here???I know I've said this 10-20 times to you before, but I will say it again: Please consider reading some books on beginning programming to at least get familiar with basic concepts like loops, arrays, setting variables, etc ....- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-04-24 : 16:44:57
|
Oh sorry about that.Basically, what am trying to achieve is to run a loop based on the number of values in the array. So that the loop will process the different values in the array csvParts[i]However, the loop was not working. So in order to test it, I tried to write out the values of the code in a loop. And increment it with the i++ But i only get the last value.Hope this is clearer. AS i only get one value back in the loopquote: >> You are just setting the label's Text property to the length of the array returned from the split over and over.
PRECISELYEhi |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-04-24 : 18:48:58
|
[code]int i = 0;do{ // get the value from the array Label1.Text += csvParts[i]+","; i++;}while (i < length -1);[/code]I got it to work. ta ! |
|
|
|
|
|
|
|