Wo liegt mein Fehler? (if-verzweigung)



  • Hi, könnt ihr mir sagen, wo mein Fehler liegt? Es ist egal was ich eingebe, er öffnet immer nur Form2!!!

    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    #include "Unit2.h"
    #include "Unit3.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    TForm2 *Form2;
    TForm3 *Form3;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    
    void __fastcall TForm1::Edit1Change(TObject *Sender)
    {
     String eingabe;
     String L;
     if(eingabe == L)
     {
      Form2 -> Show();
     }
     String B;
     if(eingabe == B)
     {
      Form2 -> Show();
     }
     else
     {
      Form3 -> Show();
     }
    
    }
    //---------------------------------------------------------------------------
    

    Wo liegt mein Fehler? 😕



  • void __fastcall TForm1::Edit1Change(TObject *Sender)
    {
     String eingabe;
     if(eingabe == "L" || eingabe == "B")
     {
      Form2 -> Show();
     }
      else
     {
      Form3 -> Show();
     }
    
    }
    


  • void __fastcall TForm1::Edit1Change(TObject *Sender)
    {
     String eingabe = Edit1->Text;
     if(eingabe == "L" || eingabe == "B")
     {
      Form2 -> Show();
     }
      else
     {
      Form3 -> Show();
     }
    
    }
    


  • Du weist den Variablen dohc garnirgends werte zu? Prüfe doch mal den Inhalt der Variablen mit dem Watchwindow...

    -junix



  • Danke für die schnelle Hilfe, jetzt funktionierts!


Anmelden zum Antworten