parse text object for INT string?

  • Thread starter Thread starter Stephen Russell
  • Start date Start date
S

Stephen Russell

I have been tasked to run through textbox and determine it's numeric
equivalent.

ALL-13A, FLR-145, ZX-1X MAK-145ZD are all valid data in the textbox.
13, 145, 1, 145 are the values I need to pull out.

How can I find the telltale "-" mark? And then is there a function like
IsNumeric?

TIA
Stephen Russell

S.R. & Associates

Memphis TN 38115

901.246-0159

"I choose a block of marble and chop off whatever I don't need."

- Francois-Auguste Rodin (1840-1917), when asked how he managed to make his
remarkable statues
 
Hi Stephen
There is no IsNumeric method.
what you can do is to convert your string to a chararray and
parse the array with char.IsNumber for checking if its a number.
hope this helps
stefan
 
I have been tasked to run through textbox and determine it's numeric
equivalent.
ALL-13A, FLR-145, ZX-1X MAK-145ZD are all valid data in the textbox.
13, 145, 1, 145 are the values I need to pull out.
How can I find the telltale "-" mark? And then is there a function
like IsNumeric?

Take a look at the Regex() class in System.Text.RegularExpressions
namespace. It has everything you need to do this.

-mbray
 
I have been tasked to run through textbox and determine it's
numeric equivalent.

ALL-13A, FLR-145, ZX-1X MAK-145ZD are all valid data in the
textbox. 13, 145, 1, 145 are the values I need to pull out.

How can I find the telltale "-" mark? And then is there a
function like IsNumeric?

Stephen,

You can use a regular expression to pull out just the number

string input = "ALL-13A";
Match m = Regex.Match(input, @"(?<number>\d+)");
int number = int.Parse(m.Groups["number"].ToString());


Hope this helps.

Chris.
 
Thanks!


__Stephen


Chris R. Timmons said:
I have been tasked to run through textbox and determine it's
numeric equivalent.

ALL-13A, FLR-145, ZX-1X MAK-145ZD are all valid data in the
textbox. 13, 145, 1, 145 are the values I need to pull out.

How can I find the telltale "-" mark? And then is there a
function like IsNumeric?

Stephen,

You can use a regular expression to pull out just the number

string input = "ALL-13A";
Match m = Regex.Match(input, @"(?<number>\d+)");
int number = int.Parse(m.Groups["number"].ToString());


Hope this helps.

Chris.
 
Back
Top