So i'm trying to strip data from a string because I have in WPF a "preset" input which looks like __,___
, now a user must input something like 30,589
, but when a user just gives in 5
or 50
, it needs to strip the rest (keeping the ,
) to propperly make a float of the input value. The code that I have right now looks like this;
if (inp_km.Text == "__,___")
{
team_results.results[inp_tour_part.SelectedIndex].km =
float.Parse("00,000",
NumberStyles.AllowDecimalPoint,
CultureInfo.GetCultureInfo("nl-NL")); // Give the new value
}
else
{
team_results.results[inp_tour_part.SelectedIndex].km =
float.Parse(inp_km.Text,
NumberStyles.AllowDecimalPoint,
CultureInfo.GetCultureInfo("nl-NL")); // Give the new value
}
But this code just check wether the input is left blank or not... Could someone help me out?
Edit
So I've included a screen, this is the input lay-out a user gets;
Os you can see, the inputs are 'pre-filled', the content of such an input is a "string", so, let's say, I type into the first input just 5;
Then the value (retreived in C# by input_name.Text
) is 5_:__
, but that's a "wrong" value and you can't fill in such things, how could I check if there still is a :
or _
in the input.
Also, the bottom input is the same, but then it needs to be filled in completely.