Autor Beitrag
mangaka
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

windows xp sp2
Delphi 2005 personal
BeitragVerfasst: Mi 01.02.06 18:48 
Hi Leute,
Ich sitze grad an meinem Rechner und wollte eine Methode schreiben, die ein Editfeld und ReferenzVariable als Parameter hat. Die Methode sollte einfach den String aus dem Feld auslesen und in die Variable speichern, wobei es sich bei der Variable um ne Double Variable handelt, weshalb ich es noch umwandeln muss. Schließlich wollte ich über try and catch die potenzielle Fehlermeldung abfangen.
Mein Problem:
Ich schaffe es einfach nicht meine Komponente zu übergeben...
Meine Code sah ungefähr so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
LeseZahlein(Comp: TEdit; var Referenzvariable: Double);
begin
  //Ohne try-catch klausel
  Referenzvariable:=StrToFloat(Comp.Text);

end;


So ne Frage nebenbei: muss der Name der "Referenzvariable" die gleiche sein wie die Globale?

Thx
mangaka

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mi 01.02.06 19:26 
Nein die Namen müssen nicht übereinstimmen, das ist ja quasi einmal die SIcht von Inne und einmal von Außen.

Ich weiß jetzt aber nicht wo das Problem sein soll, hast doch alles richtig gemacht.
Was schaffst du denn da nicht?

Das procedure/function hast du hoffentlich absichtlich weggelassen?
mangaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

windows xp sp2
Delphi 2005 personal
BeitragVerfasst: Mi 01.02.06 20:13 
jo, das habe ich wohl(unabsichtlich^^)

also er spuckt diese fehlermeldung aus, wenn ich das schreibe:
...
das wollte ich grade schreiben...
aber jetzt gehts...
KOMISCH Oo

SRY für die belestigung, aber vllt habt ihr glück und ich komm gleich trozdem net weiter ^^

Danke trozdem für die schnelle Antwort :)

cya
mangaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

windows xp sp2
Delphi 2005 personal
BeitragVerfasst: Mi 01.02.06 20:18 
ah siehste, nächstes problem:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.LeseZahlen(Comp: TEdit; var zahl);
begin
  zahl:=StrToFloat(Comp.Text); // hier liegt wohl der fehler :)
end;

Fehler: [Error] pqformel.pas(44): Operator not applicable to this operand type

und

ausblenden Delphi-Quelltext
1:
2:
//bei nem button z.b.
Form1.LeseZahlen(EdP; dP);  //edp ist die teditkomp. und dp ne double var

Fehler: [Error] pqformel.pas(49): Not enough actual parameters

hoffe du kannst mir helfen...

thx

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
WileECoyote
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82



BeitragVerfasst: Mi 01.02.06 20:35 
hi,

grob geschätzt würde ich sagen, hast du den variablentyp bei "zahl" vergessen??

gruß, Wile E.

_________________
Wer in diesem Beitrag Rechtschreibfehler findet...darf sie behalten
mangaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

windows xp sp2
Delphi 2005 personal
BeitragVerfasst: Mi 01.02.06 20:53 
lol, ja, daran könnte der erste fehler liegen..
aber der 2. fehler bleibt harnäckig...
WileECoyote
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82



BeitragVerfasst: Mi 01.02.06 21:35 
versuch doch mal "Form1.LeseZahlen(EdP, dP);"
anstatt "Form1.LeseZahlen(EdP; dP);"

gruß, Wile E.

_________________
Wer in diesem Beitrag Rechtschreibfehler findet...darf sie behalten
mangaka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

windows xp sp2
Delphi 2005 personal
BeitragVerfasst: Mi 01.02.06 21:48 
diese höchst komplexe syntax... sollte ich mir hinter die ohren schreiben.

Vielen Dank Leutz es hat funktioniert. Mein persönlicher Dank geht an
WileECoyote.

THX :)
gute nacht noch