AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Wie kann ich das rechnen

Ein Thema von Gehstock · begonnen am 2. Aug 2006 · letzter Beitrag vom 19. Aug 2006
Antwort Antwort
Seite 2 von 4     12 34      
Benutzerbild von Martin K
Martin K

Registriert seit: 20. Okt 2005
919 Beiträge
 
Turbo Delphi für Win32
 
#11

Re: Wie kann ich das rechnen

  Alt 3. Aug 2006, 22:25
Zitat von Gehstock:
tolerance := floattostr((strtofloat((pnl_result.caption)/100)*prozent));
Wenn du mir verrätst, von welchem Typ tolerance ist, dann verrat ich dir auch, ob FloatToStr an dieser Stelle funktioniert oder nicht.
Selbes gilt für prozent.

Des Weiteren wäre es auch nicht verkehrt uns mitzuteilen, welche Fehlermeldungen kommen.
Mit den Menschen ist es wie mit Computern -
es gibt Nullen und Einsen.
  Mit Zitat antworten Zitat
Klaus01
Online

Registriert seit: 30. Nov 2005
Ort: München
5.757 Beiträge
 
Delphi 10.4 Sydney
 
#12

Re: Wie kann ich das rechnen

  Alt 4. Aug 2006, 07:56
tolerance := floattostr( (strtofloat(pnl_result.caption)/100)*prozent); Sollte gehen wenn Prozent ein Integer- oder Floatwert ist und tolerance ein String ist.

Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#13

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 10:27
ich werds nie raffen

Delphi-Quellcode:
widerstand : string;
tolerance: extended;
prozent: extended;
tolerance := floattostr( (strtofloat(widerstand)/100)*(prozent)); und hier die Formel mit dem Problem

Delphi-Quellcode:
pnl_worstcasemin.caption := (floattostr((strtofloat(widerstand)/
1-(tolerance))+' Ohm'));
die klappt einwandfrei

Delphi-Quellcode:
pnl_result.caption := (floattostr((strtofloat(widerstand)/
1))+' Ohm');
Marcel
  Mit Zitat antworten Zitat
Benutzerbild von _frank_
_frank_

Registriert seit: 21. Feb 2003
Ort: Plauen / Bamberg
922 Beiträge
 
Delphi 3 Professional
 
#14

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 10:48
wenn ich das richrig sehe, hast du die klammern falsch gesetzt...

Delphi-Quellcode:
//aus
pnl_worstcasemin.caption := (floattostr((strtofloat(widerstand)/1-(tolerance))+' Ohm'[color=#ff0000])[/color]);
//wird
pnl_worstcasemin.caption := (floattostr((strtofloat(widerstand)/1-(tolerance))[color=#00ff00])[/color]+' Ohm');
//achja, division durch 1 und die stringroutinen...
var widerstand:extended;
pnl_worstcasemin.caption := floattostr(widerstand-tolerance)+' Ohm';
lässt sich doch viel leichter lesen, oder?

//edit
@mkinzler (nachfolgendes post): hab mich schon gewundert...wegen dem /(1-tolerance), er hat die prozentuale toleranz schon.
warum hast du das farbige komplett raus? hätte Eindruck gemacht.

Gruß Frank
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#15

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 10:52
Du scheinst uns nicht zu trauen, da du unsere Ratschläge mit einer Bestimmtheit igonierst.
Man rechnet nicht mit strings.
widerstand : Extended; tolerance := widerstand/100*prozent; pnl_worstcasemin.caption := floattostr(widerstand-tolerance)+' Ohm'; pnl_result.caption := floattostr(widerstand)+' Ohm';
Markus Kinzler
  Mit Zitat antworten Zitat
Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#16

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 11:13
Dsa klappt so net immer wenn ich irgendwas verändere klappt was anderes wieder nicht

deswegen mal komplett nich meckern binn noch nicht fertig mit dem optimieren der Normwiderstände

Delphi-Quellcode:
procedure TForm2.btn_executeClick(Sender: TObject);
var
wert : string;
widerstand : string;
tolerance: string;
prozent: extended;

begin
if rb_4rings.Checked then begin ++++++wollte ich umstellen (case) tut dann aber auch dumm
wert := floattostr(((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex);
if cb_ring3.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
if cb_ring3.ItemIndex = 1 then widerstand := floattostr((strtofloat(wert)/10));
if cb_ring3.ItemIndex = 2 then widerstand := floattostr((strtofloat(wert)*1));
if cb_ring3.ItemIndex = 3 then widerstand := floattostr((strtofloat(wert)*10));
if cb_ring3.ItemIndex = 4 then widerstand := floattostr((strtofloat(wert)*100));
if cb_ring3.ItemIndex = 5 then widerstand := floattostr((strtofloat(wert)*1000));
if cb_ring3.ItemIndex = 6 then widerstand := floattostr((strtofloat(wert)*10000));
if cb_ring3.ItemIndex = 7 then widerstand := floattostr((strtofloat(wert)*100000));
if cb_ring3.ItemIndex = 8 then widerstand := floattostr((strtofloat(wert)*1000000));
if cb_ring3.ItemIndex = 9 then widerstand := floattostr((strtofloat(wert)*10000000));
end;

if rb_5rings.Checked then begin
wert := floattostr(((cb_ring1.ItemIndex+1)*100) + ((cb_ring2.ItemIndex)*10) + (cb_ring53.ItemIndex));
if cb_ring54.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
if cb_ring54.ItemIndex = 1 then widerstand := floattostr((strtofloat(wert)/10));
if cb_ring54.ItemIndex = 2 then widerstand := floattostr((strtofloat(wert)*1));
if cb_ring54.ItemIndex = 3 then widerstand := floattostr((strtofloat(wert)*10));
if cb_ring54.ItemIndex = 4 then widerstand := floattostr((strtofloat(wert)*100));
if cb_ring54.ItemIndex = 5 then widerstand := floattostr((strtofloat(wert)*1000));
if cb_ring54.ItemIndex = 6 then widerstand := floattostr((strtofloat(wert)*10000));
if cb_ring54.ItemIndex = 7 then widerstand := floattostr((strtofloat(wert)*100000));
if cb_ring54.ItemIndex = 8 then widerstand := floattostr((strtofloat(wert)*1000000));
if cb_ring54.ItemIndex = 9 then widerstand := floattostr((strtofloat(wert)*10000000));
end;
begin
if StrTofloat(widerstand)>=1000000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/
1000000))+' MOhm');
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
end;
if StrTofloat(widerstand)>=1000 then begin
if StrTofloat(widerstand)<1000000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/
1000))+' KOhm');
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
end;
end;
if StrTofloat(widerstand)<1000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/ ++++++das klappt
1))+' Ohm');
pnl_worstcasemin.caption := (floattostr((strtofloat(widerstand)/ ++++++und hier das problem
1+(tolerance))+' Ohm'));
pnl_worstcasemax.caption := (floattostr((strtofloat(widerstand)/ ++++++und hier das problem
1+(tolerance))+' Ohm'));
end;
tolerance := floattostr( (strtofloat(widerstand)/100)*(prozent));
if rb_5rings.Checked then begin

if cb_ring55.ItemIndex = 0 then begin ++++++wollte ich umstellen (case) tut dann aber auch dumm
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
end;
if cb_ring55.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
end;
if cb_ring55.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
end;
if cb_ring55.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
end;
if cb_ring55.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
end;
if cb_ring55.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
end;
end;

if rb_4rings.Checked then begin

if cb_ring4.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '10%';
prozent:=(10);
end;
if cb_ring4.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
end;
if cb_ring4.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
end;
if cb_ring4.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
end;
if cb_ring4.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
end;
if cb_ring4.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
end;
if cb_ring4.ItemIndex = 6 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
end;
end;

end;
end;



procedure TForm2.btn_execute_preresistClick(Sender: TObject);

begin +++hier bin ich noch nicht fertig mit umbauen
case trunc(resistor) of +++seit ich das so hab bleibt das panel beim ersten
 25000..33001:pnl_normresistor.Caption := '27 KOhm'; +++drücken des Buttons leer erst beim 2. betätigen
 16500..22001:pnl_normresistor.Caption := '22 KOhm'; +++erfolgt die ausgabe
 13500..16499:pnl_normresistor.Caption := '18 KOhm';
 12000..13499:pnl_normresistor.Caption := '15 KOhm';
10000..11999:pnl_normresistor.Caption := '12 KOhm';
8200..9999:pnl_normresistor.Caption := '10 KOhm';
6800..8199:pnl_normresistor.Caption := '8,2 KOhm';
5600..6799:pnl_normresistor.Caption := '6,8 KOhm';
4700..5599:pnl_normresistor.Caption := '5,6 KOhm';
3900..4699:pnl_normresistor.Caption := '4,7 KOhm';
3300..3899:pnl_normresistor.Caption := '3,9 KOhm';
2200..3299:pnl_normresistor.Caption := '3,3 KOhm';
end;
 {else
  case trunc(resistor*10) of
    1..12://ist (0.1)..(1.2)      alles mit kommastellen hier rein
  end;
}

 begin
if (Resistor)>2200 then begin
  if (Resistor)<3301 then
pnl_normresistor.Caption := (floattostr(2.2)+' KOhm')
end;
 end;
 begin
if (Resistor)>1625 then begin
  if (Resistor)<2201 then
pnl_normresistor.Caption := (floattostr(1.8)+' KOhm')
end;
 end;
 begin
if (Resistor)>1500 then begin
  if (Resistor)<1626 then
pnl_normresistor.Caption := (floattostr(1.5)+' KOhm')
end;
 end;


usw......
 end;
Marcel
  Mit Zitat antworten Zitat
Benutzerbild von _frank_
_frank_

Registriert seit: 21. Feb 2003
Ort: Plauen / Bamberg
922 Beiträge
 
Delphi 3 Professional
 
#17

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 11:28
Zitat von Gehstock:
Delphi-Quellcode:
wert : string;
widerstand : string;
tolerance: string;
...
if cb_ring3.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
MAN RECHNET NICHT MIT STRINGS!!!!!!!!!
.oO(ist denn das so schwer zu verstehen?)

sorry admins, war jetzt mal nötig...

@gehstock: bring erstmal das in ordnung...(und danach die Einrückungen, damit dein Code lesbar wird)

Gruß Frank
  Mit Zitat antworten Zitat
Klaus01
Online

Registriert seit: 30. Nov 2005
Ort: München
5.757 Beiträge
 
Delphi 10.4 Sydney
 
#18

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 11:35
Delphi-Quellcode:
if rb_4rings.Checked then
begin ++++++wollte ich umstellen (case) tut dann aber auch dumm
  wert := floattostr(((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex);
  if cb_ring3.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
  if cb_ring3.ItemIndex = 1 then widerstand := floattostr((strtofloat(wert)/10));
  if cb_ring3.ItemIndex = 2 then widerstand := floattostr((strtofloat(wert)*1));
  if cb_ring3.ItemIndex = 3 then widerstand := floattostr((strtofloat(wert)*10));
  if cb_ring3.ItemIndex = 4 then widerstand := floattostr((strtofloat(wert)*100));
  if cb_ring3.ItemIndex = 5 then widerstand := floattostr((strtofloat(wert)*1000));
  if cb_ring3.ItemIndex = 6 then widerstand := floattostr((strtofloat(wert)*10000));
  if cb_ring3.ItemIndex = 7 then widerstand := floattostr((strtofloat(wert)*100000));
  if cb_ring3.ItemIndex = 8 then widerstand := floattostr((strtofloat(wert)*1000000));
  if cb_ring3.ItemIndex = 9 then widerstand := floattostr((strtofloat(wert)*10000000));
end;
eine Rechnung durch 100 entspricht einer Multiplikation mit 0.01 // ItemIndex = 0
eine Rechnung durch 10 entspricht einer Multiplikation mit (0.01 *10^1) -> 0.1 // ItemIndex = 1
eine Rechnung * 1 entspricht einer Multiplikation mit (0.01 *10^2) -> 1 // ItemIndex = 2

->

wenn dann wert ein Typ float ist
und widerstand auch

Delphi-Quellcode:
if rb_4rings.checked then
  begin
    wert := ((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex;

    widerstand := wert * 0.01 * power(10,cb_rings3.ItemIndex);
  end;
Ist etwas kürzer und hoffentlich auch richtig.
Habe es nicht ausprobiert.

Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#19

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 12:06
Ist es Danke
ging ja alles von ganz alleine auser die toleranz

Delphi-Quellcode:
procedure TForm2.btn_executeClick(Sender: TObject);
var
wert : extended;
widerstand : extended;
tolerance: extended;
prozent: extended;

begin
if rb_4rings.Checked then begin
wert := ((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex;
widerstand := wert * 0.01 * power(10,cb_ring3.ItemIndex);
 end;

if rb_5rings.Checked then begin
wert := ((cb_ring1.ItemIndex+1)*100) +((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex;
widerstand := wert * 0.01 * power(10,cb_ring54.ItemIndex);
 end;
begin
if (widerstand)>=1000000 then begin
pnl_result.caption := (floattostr((widerstand)/1000000))+' MOhm';
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
 end;
if (widerstand)>=1000 then begin
 if (widerstand)<1000000 then begin
pnl_result.caption := (floattostr((widerstand)/1000))+' KOhm';
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
 end;
  end;
if (widerstand)<1000 then begin
pnl_result.caption := (floattostr((widerstand)/1))+' Ohm';
pnl_worstcasemin.caption := (floattostr((widerstand)/1-(tolerance)))+' Ohm'; +++++da ist der Fehler
pnl_worstcasemax.caption := (floattostr((widerstand)/1+(tolerance)))+' Ohm'; ?????falsche klammer
 end;
tolerance := (widerstand)/100*(prozent);
if rb_5rings.Checked then begin

if cb_ring55.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
 end;
if cb_ring55.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
 end;
if cb_ring55.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
 end;
if cb_ring55.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
 end;
if cb_ring55.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
 end;
if cb_ring55.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
 end;
 end;

if rb_4rings.Checked then begin

if cb_ring4.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '10%';
prozent:=(10);
 end;
if cb_ring4.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
 end;
if cb_ring4.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
 end;
if cb_ring4.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
 end;
if cb_ring4.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
 end;
if cb_ring4.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
 end;
if cb_ring4.ItemIndex = 6 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
end;
 end;
  end;
   end;
Marcel
  Mit Zitat antworten Zitat
Klaus01
Online

Registriert seit: 30. Nov 2005
Ort: München
5.757 Beiträge
 
Delphi 10.4 Sydney
 
#20

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 12:13
Delphi-Quellcode:
if (widerstand)<1000 then
  begin
    pnl_result.caption := floattostr(widerstand)+' Ohm';
    pnl_worstcasemin.caption := floattostr(widerstand-tolerance)+' Ohm'; +++++da ist der Fehler
    pnl_worstcasemax.caption := floattostr(widerstand +tolerance)+' Ohm'; ?????falsche klammer
  end;
Du hast ja anscheinend eine Klammermanie, soviele unnötige Klammern, da
kommt man schon durcheinander.

Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 4     12 34      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:47 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