Link to home
Start Free TrialLog in
Avatar of webkiwi1
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


ASKER CERTIFIED SOLUTION
Avatar of bluefezteam
bluefezteam

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webkiwi1
webkiwi1

ASKER

Thank you for the reponses. I have tried all three solutions and only bluefezteam seemed to work for me (not to say the others did not). The errors I got from both elimesika:and jaime_olivares:was "Input string in the wrong format" or similar...I think it was having problems with the comma.

Awarding points accordingly.
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.
No problem, worked this time...I thought that may be the case.