473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

IsDecimal or IsNumber

Does anyone know of a way to check a string... being a Number or Decimal...

~~~without exception handling?

(Exceptional Handling is slow ... and it shows on this one)
Here is the gist...but with crappy ExceptionHandling code.:::::::
private static bool IsDecimal(string theValue)
{
bool returnVal = false;
try
{
Convert.ToDouble(theValue , CultureInfo.CurrentCulture );
returnVal = true;
}
catch (FormatException fe)
{
returnVal = false;
}
catch (OverflowException ofe)
{
returnVal = false;
}
finally
{
}

return returnVal;

} //IsDecimal
Jan 26 '07 #1
2 13554
"sloan" <sl***@ipass.netwrote in message
news:Oh*************@TK2MSFTNGP02.phx.gbl...
Does anyone know of a way to check a string... being a Number or
Decimal...
http://msdn2.microsoft.com/en-us/lib....tryparse.aspx
Jan 26 '07 #2
Duhhh. (to myself).

Thanks Mark..........its been a long week.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uW*************@TK2MSFTNGP02.phx.gbl...
"sloan" <sl***@ipass.netwrote in message
news:Oh*************@TK2MSFTNGP02.phx.gbl...
Does anyone know of a way to check a string... being a Number or
Decimal...

http://msdn2.microsoft.com/en-us/lib....tryparse.aspx


Jan 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: laredotornado | last post by:
Hello, I'm using PHP 4 and I was wondering if there was a function, or an easy way to check if a variable is a number. THe "intval" function doesn't work very well for me because if the variable...
13
by: Rainer Deyke | last post by:
Now that rexec is gone, is there any code or information available on executing Python in a restricted environment? And before I roll my own solution, exactly where the security holes in rexec...
4
by: Rob Hunter | last post by:
How do I check if a value is a number in Python? One way is (x == type(1)) and (x == type(1.2)) and (x == type(2387482734274)) and ... but this seems kludgy. Any better way? Thanks, Rob
2
by: Rick Palmer | last post by:
The code below is a class I am creating in order to help facilitate a generic "data layer" assembly. Anyway, as you see the RecordCriteria class contains three hashtables, and a structure called...
2
by: Jefe | last post by:
Hi Group Could you please explain to me what's the difference between Chars.IsDigit and Chars.IsNumber? Regards,
2
by: Rick Palmer | last post by:
The code below is a class I am creating in order to help facilitate a generic "data layer" assembly. Anyway, as you see the RecordCriteria class contains three hashtables, and a structure called...
20
by: Keith | last post by:
The following control code - only allows for the entry of numbers, backspace, and decimals (or periods). The problem lies in the last statement - it allows multiple decimals or periods. How...
4
by: sang | last post by:
I am trying to get the number that are present in the input string by using the isNumber(), but i have no idea about that any one help me. input for the program is "java123" output is only "123"...
3
by: MooMaster | last post by:
N00b question alert! I did a search for isdigit() in the group discussion, and it didn't look like the question had been asked in the first 2 pages, so sorry if it was... The manual...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.