Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   unbekannter fehler in c++ programm (https://www.delphipraxis.net/17103-unbekannter-fehler-c-programm.html)

PomBär 28. Feb 2004 10:35


unbekannter fehler in c++ programm
 
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)));
}
//---------------------------------------------------------------------------
:wiejetzt:

[edit=r_kerber]Code-Tags gesetzt. Mfg, r_kerber[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz