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



BeitragVerfasst: Sa 20.11.04 12:10 
also, ich komme hier einfach nicht weiter:

Ich möchte ein Programm programmieren, welches die 'e's in einem Wort zählt.
So weit bin ich jetzt gekommen:


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.Button1Click(Sender: TObject);

var
z:integer;
laenge:integer;
anzahl:integer;
begin

anzahl:=0;
laenge:=Edit1.maxlength;

for z:=0 to laenge do

if laenge:='e' then
anzahl:=anzahl+1;

Label1.Caption:=IntToStr(anzahl);


end;

end.


Unten steht: "Ausdruckstyp muss Boolean sein"


Moderiert von user profile iconChristian S.: Topic aus Neue Einträge / Hinweise / etc. verschoben am Sa 20.11.2004 um 12:12
Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
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: Sa 20.11.04 12:13 
ein fehler ist schon mal hier
ausblenden Quelltext
1:
if laenge:='e' then					

Das muss so heißen:
ausblenden Quelltext
1:
if laenge='e' then					
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: Sa 20.11.04 12:15 
if Edit1.Text[z]='e' then
anzahl:=anzahl+1;

Also nur =, nicht := - sonst wärs eine Zuweisung; und String[index] - also z

AXMD
Feneriumpower Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.11.04 12:16 
Ok, das habe ich verbessert, aber jetzt steht da nten noch "inkompatible Typen"
Feneriumpower Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.11.04 12:19 
AXMD hat folgendes geschrieben:
if Edit1.Text[z]='e' then
anzahl:=anzahl+1;

Also nur =, nicht := - sonst wärs eine Zuweisung; und String[index] - also z

AXMD


Das vesteh ich nicht so ganz, wofür steht z.B. das z in deinem Beispiel?
Und wie würde es denn in meinem Beispiel aussehen?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 20.11.04 12:20 
1. nicht edit1.maxlength sondern length(edit1.text)
2. if edit1.text[z] = 'e' then
Feneriumpower Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.11.04 12:24 
OK, danke Leute, es hat funktiniert. Tolle Community hier, muss ich schon sagen. :D
Feneriumpower Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.11.04 13:04 
Noch eine Frage:
Was genau macht eigentlich length?
Gibt es die länge eines wortes in Zahlen an oder was macht es?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Sa 20.11.04 13:25 
es gibt dir die länge eines Strings zurück (also die Anzahl zeichen die er enthält)
ich wage mich aber zu erinnern, dass das auch in der Delphi Hilfe steht

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 20.11.04 13:29 
wenn du auch die E's zählen willst:

ausblenden Delphi-Quelltext
1:
if(edit1.text[z] = 'e') OR (edit1.text[z] = 'E') then					
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 20.11.04 13:31 
ausblenden Delphi-Quelltext
1:
if UpCase(Edit1.Text[z]) = 'E' then					

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 20.11.04 13:33 
Geht das mit großem und kleinem e?
Johannes Maier
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 173

Win XP
D7 Prof
BeitragVerfasst: Mo 22.11.04 16:03 
Klar, erst macht UpCase Edit1.Text[z] groß, danach testet es, ob es ein großes 'E' ist. Wenn der Buchstabe vorher schon groß war, wird er nicht wieder klein gemacht ;)

_________________
MfG
Johannes ehem. jbmaier
yogo
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 121

Windowse, Linuxe
Delphi 3 Prof., D5 Enterprise, D6 Enterprise, Kylix, Delphi 2010
BeitragVerfasst: Do 02.12.04 20:11 
Titel: Integer als Buchstabe?
Wie soll man denn den Integer zu einem Buchstaben machen?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Do 02.12.04 20:18 
Titel: Re: Integer als Buchstabe?
yogo hat folgendes geschrieben:
Wie soll man denn den Integer zu einem Buchstaben machen?

Ich sag jetzt einfach mal chr(), auch wenn sich mir ein wenig der Zusammenhang verschließt. :nixweiss:

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Feneriumpower Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: So 05.12.04 00:37 
Ok, die Aufgabe wäre erledigt, habe aber noch eine andere.
Jetzt soll das Programm noch anzeigen, an welcher position sich das erste 'E' bzw 'e' befindet. Wie geht das?
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: So 05.12.04 00:47 
Indem du zuerst mal ne Boolsche Variable auf true setzt...wenn du dann ein E Gefunden hast, setzte die auf false...und wenn du dann eben ein E gefunden hast, und die Variable auf true steht, dann gibste eben das E aus....und setzt die Variable auf false....
oder du baust einen Zähler ein, den du immer um Eins erhöhst, wenn ein E gefunden wurde, und wenn dann der Zähler auf eins steht, ist das das erste zeichen und du gibts es aus*g*
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: So 05.12.04 07:55 
ausblenden Delphi-Quelltext
1:
Stelle:=Pos('e',LowerCase(Edit1.Text));					

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!