Thema: Delphi Vokale Zählen

Einzelnen Beitrag anzeigen

userF

Registriert seit: 12. Jun 2006
33 Beiträge
 
#32

Re: Vokale Zählen

  Alt 18. Jun 2006, 12:40
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
EdtSatz: TEdit;
LblVokNum: TLabel;
LblKonstNum: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
vokal, KonstNum: Integer;
Satz: String;
begin
vokal := 0;
KonstNum := 0;

// Groß-/Kleinschreibung ignorieren
Satz := AnsiLowerCase(EdtSatz.Text);

vokal :=0;
KonstNum :=0;
for i:=1 to length(satz) do
if (satz[i] in ['a', 'e', 'i', 'u', 'o']) then
inc(vokal)
else
if satz[i] in ['a'..'z'] then
inc(KonstNum);

LblVokNum.Caption := IntToStr(vokal);
LblKonstNum.Caption := IntToStr(KonstNum);
end;

end.

So sollte es funktionieren?
  Mit Zitat antworten Zitat