hey all i was wondering if any1 no's if there is a way i can check if the value entered in a textbox has decimal places ie 2.03...i would like to no how to catch this ...
any ideas plz?
| SitePoint Sponsor |
hey all i was wondering if any1 no's if there is a way i can check if the value entered in a textbox has decimal places ie 2.03...i would like to no how to catch this ...
any ideas plz?
Code is Poetry
U could try this:
if (textbox1.Text.IndexOf(".") >= 0)
{
//Decimal does exist
}
else
{
//decimal does not exist
}
I hope this helps u. What the IndexOf method does is basically give ut the position of whatever ur looking for in the string beginning at 0 and if does not exist return -1.
I hope this makes sense
yep it does thanks![]()
Code is Poetry

Or some Regular Expressions:
Code:private bool MatchDecimal(string matchString) { Regex reg = new Regex( @"^[-+]?[0-9]\d{0,2}(\.\d{1,2})?%?$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled ); System.Text.RegularExpressions.Match result = reg.Match(matchString); return result.Success; }![]()
Hey dhtmlgod.
Ive never quite got Regex. Do u maybe have a link for me to read about how RegularExpressions work and how to write them?
What is the benefit of it apposed to using other methods?
Thanks
You can read Regular expression from :-
http://www.windowsdevcenter.com/pub/...harp_0101.html
Bookmarks