Autor Beitrag
Sinjai
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39

xp
Delphi 7
BeitragVerfasst: Di 18.03.08 09:14 
hi ich hab mal ne frage, undzwar hab ich nen taschenrechenr programmiert, der klappt auch ist alles schön und gut. doch wenn ich in ds edit feld nichts eingeben und dann auf enter, sagt er " " ist kein gültiger wert... oder sowas in der art.kann ich dem programm irgendwie sagen das es mr da zum beispiel hinschreuiben soll "bitte geben sie eine zahl ein"?


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 18.03.2008 um 09:17
Der nette Nachbar
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 67

Win XP, Suse Linux 9.3
Delphi 7, Delphi 2007, Borland C++ Builder 6, Java Builder 7
BeitragVerfasst: Di 18.03.08 09:23 
Entweder du weisst den User explizit an nur Gleitkommawerte einzutragen oder du unterbindest schlicht und einfach jegliche Ziffern ausserhalb von 0-9
Sinjai Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39

xp
Delphi 7
BeitragVerfasst: Di 18.03.08 09:27 
hmm mit welchem quellcode machn ich das?
Der nette Nachbar
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 67

Win XP, Suse Linux 9.3
Delphi 7, Delphi 2007, Borland C++ Builder 6, Java Builder 7
BeitragVerfasst: Di 18.03.08 09:55 
Schliesse einfach bei OnKeyPress alle Alphanumerischen Zeichen aus ...z.B.
ausblenden Delphi-Quelltext
1:
if not (key in  [#8,#44,#48..#57]) then					
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Di 18.03.08 11:59 
kannstes auch mit try...except...end machen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
try
.
.
.
except
showmessage('bitte geben sie eine zahl ein');
end;



würd ich so machen...die meldung wird immer angezeigt wenn du was falsches oder garnix eingibst
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 18.03.08 12:54 
user profile iconhuuuuuh hat folgendes geschrieben:
kannstes auch mit try...except...end machen
würd ich so machen...die meldung wird immer angezeigt wenn du was falsches oder garnix eingibst

Was dem Benutzer wohl ziemlich nerven dürfte andauernt eine Fehlermeldung wegzuklicken.
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Di 18.03.08 13:15 
er will doch ne eigene fehlermeldung machen...
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 18.03.08 14:28 
Und ich halte es eben für sinnvoller erst keine Fehleingabe zu zulassen.
†halia
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 24

WIN XP
Delphi 7 Enterprise, C++
BeitragVerfasst: Di 18.03.08 17:57 
Du kannst das auch mit einer Messagebox machen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if Edit1.Text='' then
   Application.MessageBox('Zahl eingeben!', 'Fehler', mb_ok)
  else
   begin
    //deine Rechenanweisungen
   end;
end;


Gruß,
†halia

_________________
"Fehler 5400 bedeutet, dass Ihr Computer Sie für einen Trottel hält und in Zukunft nichts mehr mit Ihnen zu tun haben will."