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

WIN 2000
D2006 Prof
BeitragVerfasst: Di 12.04.05 14:42 
Hi

ich bin gerade dabei einen Taschenrechner zu programmieren und möchte mit virtuellen Tastencodes wie z.b mit VK_ADD Rechenoperationen durchführen.
Klappt auch wunderbar allerdings kommt immer wenn ich die Taste VK_ADD drücke ein plus in mein Edit-Feld, wo ich die zu berechnenden Zahlen hineinschreibe und kommt immer (logischer weiße) die Fehlermeldung z.B. "2+ ist kein gültiger Gleitkommawert"
Hat jemand eine Idee wie man das Unterbinden kann das das Plus nicht mehr in das Edit-Feld geschrieben wird :?:

MfG
Radioactive
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Di 12.04.05 14:49 
Ich bin mir jetzt micht sicher, aber es sollte mit Edit1.Text := Edit1.Text + chr(8); gehen.

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 12.04.05 14:57 
Hmm?? :gruebel: Kann sein, dass ich das jetzt falsch verstanden habe, aber ich dachte eher an sowas:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Edit1Change(Sender: TObject);
var
i: Integer;
s: String;
begin
s := '';
for i := 1 to Edit1.SelStart-1 do s := s + Edit1.Text[i];
for i := Edit1.SelStart+1 to Length(Edit1.Text) do s := s + Edit1.Text[i];
Edit1.Text := s;
end;


Das löscht dir das aktuell hinzugefügte Zeichen aus deinem Edit-Feld wieder raus. Noch ne Abfrage davor, ob das Zeichen das Plus ist oder nicht und dann kanns weitergehen. ;)
Radioactive
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Di 12.04.05 15:01 
Was spricht gegen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Edit1Change(...);
begin
  if Edit1.Text[Length(Edit1.Text)] = '+' then 
    Edit1.Text := copy(Edit1.Text, 1, Length(Edit1.Text)-1);
end;

?

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
crandzy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN 2000
D2006 Prof
BeitragVerfasst: Di 12.04.05 15:53 
Danke so funktioniert es :lol:
MfG
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 12.04.05 15:55 
@Radioactive: Ihr immer mit euren Funktionen!! :mrgreen: