hi people
i need to check if the input thing is integer and another is float.
how do i that?
i think that isnumeric will not differentiate between integre and float.
Will i have to use Regex?
Thanx
VB.NET 2005
micky
hi people
i need to check if the input thing is integer and another is float.
how do i that?
i think that isnumeric will not differentiate between integre and float.
Will i have to use Regex?
Thanx
VB.NET 2005
micky
You could try this:-
Code:Try Convert.ToInt16(value) catch 'not an integer end try
Thanx RR
will this fail if the entered value is not an integer??
also, i was hoping to have something like a Regex so that i can make it in a function to use across th app!!![]()
It should throw an exception if it fails which it would if the value wasn't an integer....Originally Posted by micky
You could put this into a function....
You could use a regex match instead if you wanted...
Try something like this:-
<edit>Actually I suppose you could just use Dim regex_int as Regex = New Regex("^[0-9\.]$")</edit>Code:Dim regex_int as Regex = New Regex("^[0-9]$") Dim regex_int_dec as Regex = New Regex("^[0-9]+\.[0-9]{1,2}$") if regex_int.IsMatch(value) or regex_int_dec.IsMatch(value) then 'value matches either regex else 'value doesn't match either regex end if
Last edited by richyrich; January 9th, 2009 at 07:40 AM.
thanx RR
i'll check and revert back if some problem![]()
Another way that should work is using TryCast. See here: TryCast
jmurrayhead
If you agree, give me rep.
If you like it here...throw us a few bones to help support us.
thanx J, but i just needed regex for the two![]()
RR, the regex for float rejects integers.
shud it be like that??
Bookmarks