I need to have an entry in a cash mask, I'm trying to get some things I got from information,
void lanceMask(object sender, EventArgs e)
{
var ev = e as TextChangedEventArgs;
if (ev.NewTextValue != ev.OldTextValue)
{
var entry = (Entry)sender;
string text = Regex.Replace(ev.NewTextValue, @"[^0-9]", "");
text = text.PadRight(9);
//Removendo todos os digitos excedentes
if (text.Length > 8)
{
text = text.Remove(8);
}
if (text.Length < 5)
{
text = text.Insert(1, ".").TrimEnd(new char[] { ' ', '.', '-', ',' });
}
else
{
text = text.Insert(5, ".").Insert(7, ",").TrimEnd(new char[] { ' ', '.', '-', ',' });
}
if (entry.Text != text)
entry.Text = text;
}
}
I would like to be able to use a semicolon if I had 6 digits (ex: 1,400.00), if it is 7 digits (ex: 23,600.00), and so on.