Test Data Type

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Guadala Harry (GMan_at_NoSpam.com)
Date: 08/11/04


Date: Wed, 11 Aug 2004 10:32:15 -0700

What are the options for testing to see if a String variable contains a
value that can be converted to an integer (vs containing a value that cannot
be converted to an integer)?

e.g., "784" can be converted to an integer
whereas "nope" cannot be converted to an integer
nor can "" (a zero length string) be converted to an integer
nor can null (the 'null' value) be converted to an integer

Please note that I do not want rely on error handling for this - if the
input value cannot be converted, I need to simply skip the particular input
and proceed to processing others. AFAIK, if I rely on error handling, then
processing would have to stop - or I'd have to get into some ugly recursive
call situation - or I'd have to nest a bunch of try... catch blocks. So,
without doing this test via error handling, what are my options?

Thanks!



Relevant Pages

  • Re: Method that gets current location in code?
    ... AFAIK Exception.ToString has this info. ... The stack trace could perhaps be ... Patrice ... I'm doing some error handling in my ASP.net pages. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Error handling the "classic" way
    ... AFAIK, the Err.Clear is really only for your own purposes, because it sets ... > I'm now trying to re-visit with a more learned mind on error handling, ... Thanx in advance, as always, for your thoughtful responses. ...
    (microsoft.public.vb.general.discussion)
  • Re: Module / Sub as string
    ... Afaik no, sorry. ... It would make error handling far easier if it was. ... Is it possible to read either the module and/or the sub name and use it as ... string within the code? ...
    (microsoft.public.excel.programming)
  • Re: [PATCH] mtd: fix memory leaks in phram_setup
    ... bunch of those and put somewhere in lib/. ... error handling always clutters up our nice code. ... end of a function, after the algorithm. ... Bottlenecks ...
    (Linux-Kernel)
  • How can i skip lines under certain conditions
    ... I am writing a script which created multiple processes. ... for error handling, i need to be able to skip a bunch of statements ...
    (comp.lang.tcl)