Autor Beitrag
cola
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mo 13.06.05 20:24 
Hallo Leute,

ich hab da mal ne Frage. Ich sitze grad an nem Programm und komm nicht weiter. Wie kann ich die beiden Typen TObject und Integer kompatibel machen?

Andere Frage: Wenn ich ne ganz normale Procedure erzeuge, dann steht da immer dahinter in Klammern (Sender:TObject). Wenn ich nun so eine Procedure noch mal aufrufen möchte, (zum Beispiel in nem if-Befehl) was schreibe ich dann in die Klammer?

Ich hoffe ihr könnt mir helfen. Danke schon mal, Cola
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 13.06.05 20:27 
Bitte mache demnächst für jede Frage einen neuen Thread auf :mahn:

1) Ich weiss jetzt nicht, was du mit TObject und integer kompatibel machen meinst, aber wenn es dir nur darum geht ein TObject als Integer zu übergeben, mach den Umweg über einen Pointer - was das bringt, weiss ich allerdings nicht so richtig :?

2) Wenn du in der Prozedure nicht mit dem Sender arbeitest, kannst du in die Klammern irgendwas reinschreiben. Sender und Self sind meistens zweckmäßig. nil geht immer.


Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 13.06.05 20:33 
poste mal den quelltext.

wie mein vorredner schon gesagt hat kann man integer und TObject "kompatibel machen" - jedoch würde dein prog dann wahrscheinlich abstürzen user defined image

mit quelltext sieht das ganze ganz anders aus. dann kann dir viel besser geholfen werden ,weil dann auch ersichtlich ist, wo du den fehler machst.

_________________
[inspirationslos]
cola Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mo 13.06.05 21:03 
Hallo Leute,

hab das Problem grad durch Zufall gelöst. Aber ich hab nen anderes Problem.

Folgendes: Ich hab nen Edit-Feld in dem man nen Radius eingeben kann. Nun hab ich ein paar if-Befehle eingefügt, um die Radiuseingabe einzugrenzen. Doch wenn ich das ausprobiere ob das klappt, dann klappt zwar das was ich eingegeben hab, aber es kommt eine kleine Messagebox mit "'Radius zu klein/zu groß' ist kein gültiger Integerwert". Kann man diese Messageboxen irgendwie unterdrücken?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
if StrToInt(Edit.Text)<3 then
begin
 Edit.Text:='Radius zu klein' ;
 timer1.Enabled:=false ;
 TM_Show.Enabled:=false;
end;

if StrToInt(Edit.Text)>100 then
begin
 Edit.Text:='Radius zu groß';
 timer1.Enabled:=false;
 TM_Show.Enabled:=false ;
end;

if StrToInt (Edit.Text) = 0 then
begin
 Edit.Text:=IntToStr(1);
 timer1.Enabled:=false;
 TM_Show.Enabled:=false;
end;


Übrigens: TM_Show ist auch ein Timer

Vielen Dank schon im Vorraus, Cola

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.


Zuletzt bearbeitet von cola am Mo 13.06.05 21:22, insgesamt 1-mal bearbeitet
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 13.06.05 21:16 
Ich schätze mal Dein Timer greift danach auf den String zu.
lässt sich jetzt schlecht sagen bei dem bischen Quelltext,
machs mal so oder benutz ein zweites Edit zum Anzeigen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if StrToInt(Edit.Text)<3 then 
begin
timer1.Enabled:=false ; 
TM_Show.Enabled:=false; 
Edit.Text:='Radius zu klein' ; 
end;
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 13.06.05 21:24 
nene, ist eher nicht der timer:

wenn er erst das hier schreibt:

user profile iconcola hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if StrToInt(Edit.Text)<3 then
begin
 Edit.Text:='Radius zu klein' ;
 timer1.Enabled:=false ;
 TM_Show.Enabled:=false;
end;



und der wert nicht stimmt wird ja edit edit.text verändert.
und dann soll der text 'Radius zu klein' konvertiert werden: (das sind ja alles aufeinanderfolgende anweisungen, die der reihe nach abgearbeitet werden.)

user profile iconcola hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if StrToInt(Edit.Text)>100 then
begin
 Edit.Text:='Radius zu groß';
 timer1.Enabled:=false;
 TM_Show.Enabled:=false ;
end;



dat kann doch nicht gut gehen.

besser wäre da
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  i : Integer;
begin
  i := StrToInt(Edit.Text);
  case i of
  ...
end;

_________________
[inspirationslos]
Blackheart
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

ME
D3Prof.-D6Standard
BeitragVerfasst: Mo 13.06.05 22:55 
@ der_zaehe Stimmt !

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
var
  Radius:Integer;
begin
try
  Radius:=StrToInt(Edit1.Text);
  if Radius <3
     then
     Edit1.Text := 'Radius zu klein'
      timer1.Enabled:=false ;
      TM_Show.Enabled:=false;
   else
  if Radius > 100
     then Edit1.Text := 'Radius zu groß';
      timer1.Enabled:=false ;
      TM_Show.Enabled:=false;
     except
     ShowMessage('Keine Zahl !');
  end;
 end;
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Di 14.06.05 06:27 
user profile iconmaxk hat folgendes geschrieben:
Bitte mache demnächst für jede Frage einen neuen Thread auf :mahn:
:motz:

Und die Suchfunktion sollte zu IntToStr auch ne Menge finden...

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.