Autor Beitrag
bruder jonas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: So 05.01.03 13:03 
hallo,

habe folgende funktion
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function THauptForm.eingabewert: string; 
begin
  if (cbWerte.text <> '') or (editaname.Text <> '') then
   begin
    result := cbWerte.text or result := editname.Text;
    end
    else
    showmessage("nichts eingegeben');
    halt;
   end;

ich kriege einen fehlerhinweis in der zeile mit result.

ich will (je nach eingabe) entweder cbWerte.text oder editname.text als result zurückgeben.

wie mache ich das?

danke

(05.01. 12:13 Tino) Code-Tags hinzugefügt.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 05.01.03 13:12 
Hallo,

ist dir klar das die Halt Procedure immer aufgerufen wird?

Versuch mal folgendes:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function THauptForm.eingabewert: string; 
begin
  if cbWerte.text <> '' then
    result := cbWerte.text
  else if editaname.Text <> '' then
    result := editname.Text
  else
    begin 
      showmessage ("nichts eingegeben');
      result := '';
    end;
end;


Zuletzt bearbeitet von Tino am So 05.01.03 20:24, insgesamt 1-mal bearbeitet
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 05.01.03 19:52 
der wird nur leider auch nicht gehen, Tino:
ausblenden Quelltext
1:
2:
  result := editname.Text;
else


Wie war das doch gleich? In einer IF-Abfrage nie ein Semikolon?


Was soll eigentlich geschehen, wenn sowohl in editname, als auch in cbWerte was eingegeben wird? Soll da irgendwas besonderes passieren oder soll irgendeiner Vorrang gegenüber dem anderen haben?

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 05.01.03 20:25 
tommie-lie hat folgendes geschrieben:
der wird nur leider auch nicht gehen, Tino

Passiert schon mal... Habs geändert!
kampfkoloss23
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 96



BeitragVerfasst: Di 28.01.03 00:08 
man könnte über balablbal(var variable1:string):string;

indirekt zurückgeben.
(var verändert den eingegebnen Parameter und es wird nicht
wie normal nur ne Kopie erstellt)