Einzelnen Beitrag anzeigen

PomBär

Registriert seit: 28. Sep 2003
Ort: MV
57 Beiträge
 
Delphi 6 Professional
 
#1

unbekannter fehler in c++ programm

  Alt 28. Feb 2004, 10:35
moin leute
ich hab ein kleines programm geschrieben welches den wiederstand berechnen soll.
problem: wenn ich das programm gestartet habe, die einheiten ausgewählt und den go button betätigt habe stürzt das ganze programm ab und ich muss es wieder zurücksetzten.

Code:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
 double zahly (double a, double b)
{
   double c;
   double r1 = a;
   double r2 = b;


   if (Form1->ComboBox1->Text=="kOhm")
   {
   r1 = r1 * 1000;
   }

   if (Form1->ComboBox1->Text=="MOhm")
   {
   r1 = r1 * 1000000;
   }

   if (Form1->ComboBox2->Text=="kOhm")
   {
   r2 = r2 * 1000;
   }

   if (Form1->ComboBox2->Text=="MOhm")
   {
   r2 = r2 * 1000000;
   }


   c= 1/((1/a)+(1/b));
   return(c);
}

#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
Form2->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
   double r1, r2, rg;
   r1= StrToFloat(Edit1->Text);
   r2= StrToFloat(Edit2->Text);
   rg= zahly(r1, r2);
  //rg= (r1*r2)/ (r1+r2);
   Edit3->Text = FloatToStr(rg);

   //Edit3->Text= FloatToStr(zahly(StrToFloat(Edit1->Text), StrToFloat(Edit2->Text)));
}
//---------------------------------------------------------------------------


[edit=r_kerber]Code-Tags gesetzt. Mfg, r_kerber[/edit]
Je weniger einer weiß, desto eher glaubt er jeden Scheiß.
  Mit Zitat antworten Zitat