Autor Beitrag
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 20.09.05 20:33 
Ich habe einen Taschenrechner erstellt, der über 1EditFeld verfügt, und bei dem die Zahlen über Buttons eingegeben werden, bzw. ab jetzt auch über Tastatur. Jedoch habe ich da ein kleines Problem.
Also ein ButtonClick sieht ungefähr so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
      if Ausgabe.Text = '0' then
        Ausgabe.Text := '1'
       else Ausgabe.Text := Ausgabe.Text + '1';

In diesem Fall jetzt für Button 1

Mein Problem bei dem OnKeyDown ist jetzt, dass ich nicht weiß, wie ich hier die null löschen lassen soll.
Im Moment sieht das ganze so aus:
ausblenden Delphi-Quelltext
1:
if chr(Key) = '1' then Ausgabe.Text:=Ausgabe.Text + '1'					


Wenn ich aber nun im EditFeld die null stehen habe, steht nach dem drücken von 1 aus der Tastatur "01" da :(

greetz

Moderiert von user profile iconKlabautermann: Code- durch Delphi-Tags ersetzt
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 20.09.05 21:28 
Sry wusst net wie das mit den delphi Tags geht :oops:
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 20.09.05 21:54 
Moin!

user profile iconBorn-to-Frag hat folgendes geschrieben:
Mein Problem bei dem OnKeyDown ist jetzt

OnKeyDown? :gruebel: Du hast doch ein Editfeld, da kann man doch dann auch direkt reinschreiben... ? Hä? :?

Pack mal das ganze Projekt (aber ohne die EXE) hier in den Anhang.

cu
Narses
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 20.09.05 22:01 
Ok, ich hängs mal an.. Und: Ja, OnKeyDown :P

Ich hab jetzt alle Dateien angehängt die der gemacht hat, außer EXE und so.. Also such dir raus was du brauchst :D :P
THX for help!

greetz
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 20.09.05 22:03 
Moin!

Shit, sorry, mein Fehler, hatte vergessen zu erwähnen, dass ich RARs nicht so ohne weiteres auspacken kann; kannste das bitte in ZIP ändern? :wink:

cu
Narses
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 20.09.05 22:06 
Aber na klar... Für dich doch immer ;)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 20.09.05 22:09 
Moin!

Es ist so wie ich sagte, man kann einfach ins Editfeld reinschreiben... Was ist dein Problem? :gruebel:

cu
Narses
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Di 20.09.05 22:11 
Ja das kommt ja noch weg...
Ich will ja das ich es mit den Tasten machen kannm das geht ja auch, aber wenn halt eine Null im Editfeld steht soll sie halt verschwinden so wie ich es oben bei den Buttons0-9 gemacht hab ;)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 20.09.05 22:28 
Moin!

Du solltest dann lieber das OnKeyPress nehmen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
  const
    OK: Set of Char = ['0'..'9',','];
begin
  if (Key in OK) then
    if Ausgabe.Text = '0' then
      Ausgabe.Text := Key
    else
      Ausgabe.Text := Ausgabe.Text +Key;
end;

cu
Narses
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 20.09.05 22:46 
(if chr(Key) = '1' then Ausgabe.Text:=Ausgabe.Text + '1')

Wenn Ich Mich nicht ganz täusche Ausgabe.Text ist = 0 demzufolge ist doch 0+1 = 01 also

if chr(Key) = '1' then Ausgabe.Text:='1';
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 20.09.05 22:56 
Moin!

@user profile iconBlackheart666: IMHO redest du Unsinn... :wink:

cu
Narses
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 20.09.05 23:24 
OK weiss nicht so genau worauf er hinaus will, aber Taschenrechner mit Strings dann sind 5 + 9 = 59 und nicht 14.
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 21.09.05 08:01 
neinnein blackheart hat schon recht, so wie es im moment ist, ist wenn ich z.B. der rechner starte das Edit Feld auf 0, und wenn ich dann z.B. 4 drücke ist es "04", und dass soll ja weg ;)
ich werds mal versuchen so wies narres geschrieben hat
Thx :):):)

greetz
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 21.09.05 08:24 
Moin!

Ähm... :|
user profile iconBorn-to-Frag hat folgendes geschrieben:
so wies narres geschrieben

Bitte, N-A-R-S-E-S, soviel Zeit muss sein. :wink:

cu
Narses
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 21.09.05 14:40 
Ok, N-A-R-S-E-S, ich werds mir merken!
Trotzdem Danke!!! (Musste schnell in Schule, da war deine Zeit mehr für Narses.. da musste es eben Narres sein :P)

greetz