Home All Groups Group Topic Archive Search About
Author
6 Jan 2006 10:07 PM
Rob
I have a 3 character string that I want to test to see if it is a positive
integer... I could test that each individual character is >=0 and <=9... is
there a better way ?

Is there an IsInteger() function ?

Author
6 Jan 2006 11:06 PM
Herfried K. Wagner [MVP]
"Rob" <rwch***@comcast.net> schrieb:
>I have a 3 character string that I want to test to see if it is a positive
>integer... I could test that each individual character is >=0 and <=9... is
>there a better way ?


If you are using .NET 2.0, you may want to use 'Integer.TryParse'.  In .NET
1.0/1.1 you can use 'Integer.Parse' + exception handling.  Maybe using
'IsNumeric' is an option too.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
7 Jan 2006 12:55 AM
Mythran
Show quote Hide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:ubxVQXxEGHA.1396@TK2MSFTNGP11.phx.gbl...
> "Rob" <rwch***@comcast.net> schrieb:
>>I have a 3 character string that I want to test to see if it is a positive
>>integer... I could test that each individual character is >=0 and <=9...
>>is there a better way ?
>
>
> If you are using .NET 2.0, you may want to use 'Integer.TryParse'.  In
> .NET 1.0/1.1 you can use 'Integer.Parse' + exception handling.  Maybe
> using 'IsNumeric' is an option too.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>

Hmm, I have wondered for a long while why they didn't make a TryParse for
Integer...they did for Double...

<shrug>

:)

Mythran
Author
9 Jan 2006 5:01 PM
Carlos J. Quintero [VB MVP]
You can read the historic reason for the existence Double.TryParse in
previous versions at:

http://msdn.microsoft.com/msdnmag/issues/06/01/CLRInsideOut/default.aspx

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio 2005, Visual Studio .NET,
VB6, VB5 and VBA
You can code, design and document much faster in VB.NET, C#, C++ or VJ#
Free resources for add-in developers:
http://www.mztools.com

Show quoteHide quote
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> escribió en el mensaje
news:OeM2bUyEGHA.564@TK2MSFTNGP10.phx.gbl...
>
>
> Hmm, I have wondered for a long while why they didn't make a TryParse for
> Integer...they did for Double...
>
> <shrug>
>
> :)
>
> Mythran
>