Autor Beitrag
Jasmini
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

Win Millenium
D7
BeitragVerfasst: Fr 22.04.05 15:12 
Ich soll in der Schule ein Programm schreiben. Weiß aber nicht wie!

Eingabe einer Zahl durch Edit
Ausgabe über Memo
Funktionen über Button

wenn man eine Zahl eingibt, sollen die beiden rechten Stellen immer null sein.

BSP:

Aus 134 wird 100, aus -1635 wird -1600 und aus 754678 wird 754600.

??????????????????????????????????????????????????????????????????

DANKE schon mal!
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 22.04.05 15:14 
Zuerst mal: deine ?-Taste ist möglicherweise kaputt. Bitte den EDIT-Button verwenden und die überflüssigen Fragezeichen entfernen.

Zu deinem Problem: Such mal nach Length und Pos in der Delphi-Hilfe. Beispiel:

ausblenden Delphi-Quelltext
1:
Edit1.Text[10] := 'A';					


macht aus dem zehnten Zeichen von Edit1 ein A.

AXMD
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 15:15 
Beim buttonklick:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var a: integer;
begin
  a := strtointdef(edit1.text,0);
  a := (a div 100) * 100;
  memo1.lines.text := inttostr(a);
end;



(glaube du hast das problem faslch verstanden AXMD 8)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
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: Fr 22.04.05 15:19 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure Tralalaa;
var
i: Integer;
s: String;
begin
s := '';
for i := 1 to Length(Edit1.Text)-2 do s := s + Edit1.Text[i];
s := s + '00';
Edit1.Text := s;
end;

;)
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: Fr 22.04.05 15:21 
user profile iconAXMD hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
Edit1.Text[10] := 'A';					

macht aus dem zehnten Zeichen von Edit1 ein A.

Eieiei. Das dir sowas passiert... :mrgreen:

Zitat:
[Error] Unit1.pas(29): Left side cannot be assigned to

*g*
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 15:22 
macht es doch net so kompliziert, hier in einer zeile:

ausblenden Delphi-Quelltext
1:
2:
3:
begin   
  Memo1.Lines.Text := IntToStr(StrToIntDef(Edit1.Text,0) div 100 * 100);   
end;

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
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: Fr 22.04.05 15:24 
Jaja. Ist ja okay... :mrgreen:

Ich hab aber auch was übersehen. ;) Ausgabe in ein Memo. Dann kann man meinen Code auch verkürzen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure Tralalaa;
var
i: Integer;
begin
Memo1.Clear;
for i := 1 to Length(Edit1.Text)-2 do Memo1.Text := Memo1.Text + Edit1.Text[i];
Memo1.Text := Memo1.Text + '00';
end;


;)
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 15:27 
wie die nicht mal den award für die langsamste funktion '05 gewinnt :lol:

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 15:30 
wenn man das schon mit nem string machen muss dann aber bitte so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var s: String;
begin
  s := Edit1.Text;
  Memo1.Lines.text := copy(s,1,length(s)-2)+'00';
end;

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
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: Fr 22.04.05 15:30 
Bäh! :P

:mrgreen:

Warum sagt AXMD denn nichts mehr?? :gruebel: :)
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 15:34 
der ist beim wettbewerb fürs optimieren des codes schon in der vorrunde rausgeflogen :wink:

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 22.04.05 15:48 
oder so:
ausblenden Delphi-Quelltext
1:
2:
str[length(str)]:= '0';
str[length(str)-1]:= '0';
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Fr 22.04.05 15:50 
@Webspace: wollte die komplette Lösung nicht vorwegnehmen. Und Delphi hatt ich wirklich keins zur Hand :oops:

AXMD
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: Fr 22.04.05 16:04 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
oder so:
ausblenden Delphi-Quelltext
1:
2:
str[length(str)]:= '0';
str[length(str)-1]:= '0';

Was soll denn das geben, 4of? :gruebel:

user profile iconAXMD hat folgendes geschrieben:
@Webspace: wollte die komplette Lösung nicht vorwegnehmen. Und Delphi hatt ich wirklich keins zur Hand

:mrgreen: Dann ist ja okay... ;)
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 22.04.05 16:06 
Das von Fearofthedark ist nicht so gut weil bei nem sting < länge 2 ne exception auftritt :)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Malo05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 34

Windows XP Professional SP2
D5 Prof (SSL), D7 Pers, D2005 Pers
BeitragVerfasst: Fr 22.04.05 16:07 
Einmal meine Version :mrgreen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
 begin
  s := Edit1.Text;
  s[Length(s)] := '0';
  s[Length(s) - 1] := '0';
  Memo1.Text := s;
end;
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: Fr 22.04.05 16:08 
user profile iconuall@ogc hat folgendes geschrieben:
Das von Fearofthedark ist nicht so gut weil bei nem sting < länge 2 ne exception auftritt :)


Ich würde mal sagen, dass es überhaupt nicht geht. Außer ich verstehe es nicht. Weil ich glaube, dass das der selbe Weg wie von AXMD ist... :gruebel:

Oder ist str n Befehl? :gruebel: Hab auch grad kein Delphi zur Hand... :mrgreen:
Malo05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 34

Windows XP Professional SP2
D5 Prof (SSL), D7 Pers, D2005 Pers
BeitragVerfasst: Fr 22.04.05 16:09 
user profile iconMalo05 hat folgendes geschrieben:
Einmal meine Version :mrgreen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
 begin
  s := Edit1.Text;
  s[Length(s)] := '0';
  s[Length(s) - 1] := '0';
  Memo1.Text := s;
end;


//edit: :oops: Webspace hat bereits eine ähnliche Version gepostet, hab das übersehen ;)
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 22.04.05 16:09 
Zitat:

Einmal meine Version


nee meine ! war zuerst da !
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: Fr 22.04.05 16:11 
Achsooo... 4of = Malo05... ;) str soll einfach n Temp-String sein... ;)


//EDIT: :rofl: Da hat wohl wieder jemand den Edit-Button mit dem Zitat-Button verwechselt. ;)