webkiwi1
asked on
Format a string VB.Net, VS2005
Hello experts,
I may be crazy, but I need to allow the user to input a selection of numbers in to a text box. I have provide directions to separte each by comma's, but you know how that goes.
This is much the same as the "Print range" in the common printer dialog box where you can put pages 1, 5, 8, 22
The output needs to be reformatted so that each entry is 4 digits (preceeding zero's if necessary) and separated by commas.
So, if the user puts in "1, 35, 400" the resulting string will be "0001,0035, 0400".
Basically seperating by the comma's, and then reformatting to four digits (pad left with zero?)
Less important, but I am also not sure if there is a way to account for other variations ("1 35 400", "1-35/400" etc) and have the the resulting output string still be "0001,0035, 0400".
Thanks in advance,
webkiwi
I may be crazy, but I need to allow the user to input a selection of numbers in to a text box. I have provide directions to separte each by comma's, but you know how that goes.
This is much the same as the "Print range" in the common printer dialog box where you can put pages 1, 5, 8, 22
The output needs to be reformatted so that each entry is 4 digits (preceeding zero's if necessary) and separated by commas.
So, if the user puts in "1, 35, 400" the resulting string will be "0001,0035, 0400".
Basically seperating by the comma's, and then reformatting to four digits (pad left with zero?)
Less important, but I am also not sure if there is a way to account for other variations ("1 35 400", "1-35/400" etc) and have the the resulting output string still be "0001,0035, 0400".
Thanks in advance,
webkiwi
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
sorry, there is a bug in my code, this line:
Dim pages as String() = str.Split(New [Char]() {" "c})
should be:
Dim pages as String() = str.Split(New [Char]() {","c})
Hope you can test it.
Dim pages as String() = str.Split(New [Char]() {" "c})
should be:
Dim pages as String() = str.Split(New [Char]() {","c})
Hope you can test it.
ASKER
No problem, worked this time...I thought that may be the case.
ASKER
Awarding points accordingly.