Autor Beitrag
Jagg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Sa 20.11.04 16:02 
Hallo Leute ich habe diesem Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.Button1Click(Sender: TObject);
 var f : textfile;
     Wert,WKN,Kurs,Next:string;
     wknp,kursp:integer;
     euro : extended;
begin
  Assignfile(f,'C:\Wert.txt');
  reset(f);
  while not Eof(f) do
  begin
    readln(f,wert);
    wknp:=pos(',',wert);
    wkn:=copy(wert,1,wknp-1);
    Next:=copy(wert,wknp+1,length(wert));
    kursp:=pos(',',next);
    Kurs:=copy(next,1,kursp-1);
    euro:=StrToFloat(kurs)*1.95583;
    ListBox_wert.Items.Add('Wert='+wkn+' '+'Kurs= '+kurs);
  end;
  closefile(f);
end;

...kurs ist 12.45
wenn ich jetzt starte und auf dem button klicke sagt er mir ie meldung "12.45 ist kein gültiger Gleikommawert" was mache ich falsch...habe hier im forum gesucht abre keine lösung gefunden

jagg

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
sourcehunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 482

Win XP | Suse 10.1
Delphi 2005 Pers.
BeitragVerfasst: Sa 20.11.04 16:09 
Wenn du einen String in eine Gleitkommazahl umwandelst, dann musst du ',' als Dezimaltrennzeichen verwenden und nicht '.'. Welches Zeichen Delphi im Programm (nicht in der IDE!) als Dezimaltrennzeichen benutzt hängt von der Ländereinstellung ab. Du kannst es auch mit TFormatSettings ändern.

_________________
Linux und OpenSource rulez!
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 20.11.04 16:11 
Punkt oder Komma kannst du mit DecimalSeperator einstellen.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Jagg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Sa 20.11.04 19:17 
danke das hat mir sehr geholfen ???
und wie sieht es mit integer und extended aus ?
IntToFloat oder FloatToInt ?
sourcehunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 482

Win XP | Suse 10.1
Delphi 2005 Pers.
BeitragVerfasst: Sa 20.11.04 19:27 
Trunc() und Round().
Trunc -> Abschneiden des Nachkommateils.
Round -> mathematisch korrektes Runden.

_________________
Linux und OpenSource rulez!