I am trying to do a function that is a textBox contains 2 dots (.) then the last dot(.) will be deleted, so it wont be possible to write 2 dots(.) in this textbox.
When I write the second dot in this textBox, then also the first is deleted, for example if I write this string:
"0.." -> here I want the last dot to be deleted but the first dot is also deleted. I cant figure out what I am doing wrong:
private void Value2_TextChanged(Object^ sender, TextChangedEventArgs^ e)
{
String^ GetValue2 = InputValue2->Text->Trim();
int DotCount = 0;
for( int i = 0; i < GetValue2->Length; i++ )
{
if( GetValue2->Substring(i, 1) == "." )
{
DotCount = DotCount + 1;
}
if( DotCount == 2 )
{
GetValue2 = GetValue2->Replace(GetValue2->Substring(i, 1), "");
Value2->Text = GetValue2;
Value2->SelectionStart = GetValue2->Length;
break;
}
}
}