Ich habe diesen Code für gefundene Textbox1 größte Textbox2 Der Code funktioniert aber wenn ich "0" oder "0,5" mache gibt es einen Fehler (wenn es "," gibt).Textbox1 größte texbox2
Hat jemand eine Lösung für "0" oder ","?
public partial class MainWindow : Window
{
int point1, point2;
int point3, point4;
public MainWindow()
{
InitializeComponent();
point1 = point2 = 0;
point3 = point4 = 0;
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox1.Text != "") {
point1 = int.Parse(textBox1.Text);
int tt;
int uu;
tt = point1 - point2;
uu = point3 - point4;
if (tt >=uu)
texboxxol1.Background = Brushes.Yellow;
texboxxol2.Background = Brushes.White;
}
}
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
if (textBox2.Text != "")
{
point2 = int.Parse(textBox2.Text);
int tt;
int uu;
tt = point1 - point2;
uu = point2 - point1;
if (uu >= tt)
texboxxol2.Background = Brushes.White;
texboxxol1.Background = Brushes.Yellow;
}
}
well 0,5 ist keine ganze Zahl. Was würdest du erwarten/gerne? ... – Sayse
wenn ich "0,5" oder nur "0" schreibe, habe ich die Meldung: Das Eingabeformat ist falsch. – realiste
Das ist richtig. Eine Dezimalzahl ist keine ganze Zahl. Das ist kein Programmierproblem, das ist nur Mathe – Sayse