Splitting a text box with commas in it
-
Experts, I have a textbox which will generate a set of random numbers, e.g 10 , 4 , 6 , 3 , 2 , 1 .... What i need to do is to basically split this textbox up into lots of textboxes. I was originally using e.g
txt1.text = mid(txt0.text, 1,txt0.textlength - 7)
this was ok if you where using numbers below 10 but now i am not, so i have split my numbers using commas but how do i sort them into the differnet text boxes using the commas as splitting points? Many thanks Dan
-
Experts, I have a textbox which will generate a set of random numbers, e.g 10 , 4 , 6 , 3 , 2 , 1 .... What i need to do is to basically split this textbox up into lots of textboxes. I was originally using e.g
txt1.text = mid(txt0.text, 1,txt0.textlength - 7)
this was ok if you where using numbers below 10 but now i am not, so i have split my numbers using commas but how do i sort them into the differnet text boxes using the commas as splitting points? Many thanks Dan
string.Split()
is the prime choice for splitting strings by a special character of your choice. BTW: you would get into trouble if your numbers would exceed 999, your numbers include thousands separator, and your app were used by people using comma as a thousands separator (lots of West-European countries do this). :)Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
Experts, I have a textbox which will generate a set of random numbers, e.g 10 , 4 , 6 , 3 , 2 , 1 .... What i need to do is to basically split this textbox up into lots of textboxes. I was originally using e.g
txt1.text = mid(txt0.text, 1,txt0.textlength - 7)
this was ok if you where using numbers below 10 but now i am not, so i have split my numbers using commas but how do i sort them into the differnet text boxes using the commas as splitting points? Many thanks Dan
Hi Dan, How's it going. Why don't you generate your list of random numbers into a List(of Integer). Then you can use the List(of Integer) to populate the rest of the text boxes. That way you don't need to split anything. Start using the powers of the .Net Framework and you will find programming so much easier, I promise. Cheers Wayne