Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // directive
- using System.Globalization;
- // code
- decimal input = -1;
- if (decimal.TryParse(txtUserInput.Text, NumberStyles.Currency,
- CultureInfo.InvariantCulture, out input))
- {
- parameter = input.ToString();
- }
- decimal sValue = decimal.Parse(txtboxValue.Text.Trim());
- // Put Code to check whether the $ sign already exist or not.
- //Try making a function returning boolean
- //if Dollar sign not available do this
- { string LableText = string.Format("{0:c}", sValue); }
- else
- { string LableText = Convert.ToString(sValue); }
- string sValue = Convert.ToString(txtboxValue.Text.Trim());
- // Put Code to check whether the $ sign already exist or not.
- //Try making a function returning boolean
- //if Dollar sign not available do this
- { string LableText = string.Format("{0:c}", "sValue"); }
- else
- { string LableText = Convert.ToString(sValue); }
- string value = text_box_to_validate.Text;
- string myPattern = @"^$(d{1,3},?(d{3},?)*d{3}(.d{0,2})|d{1,3}(.d{2})|.d{2})$";
- Regex r = new Regex(myPattern);
- Match m = r.Match(value);
- if (m.Success)
- {
- //do something -- everything passed
- }
- else
- {
- //did not match
- //could check if number is good, but is just missing $ in front
- }
Add Comment
Please, Sign In to add comment