function TypeString(S : string): Byte; var I : Integer; Chiffre : Boolean; Lettre : Boolean; begin Result := 0; Chiffre := False; Lettre := False; for I := 1 to Length(S) do begin if S[I] in ['0'..'9'] then Chiffre := True else Lettre := True; if Chiffre and Lettre then Break; end; Result := Byte(Chiffre) + (Byte(Lettre) * 2); end; procedure TForm1.Button1Click(Sender: TObject); begin case TypeString(Edit1.Text) of 0 : ShowMessage('Vide'); 1 : ShowMessage('Chiffre'); 2 : ShowMessage('Lettre'); 3 : ShowMessage('Chiffre et lettre'); end; end;
function isInteger(S : string): boolean; var I : Integer; begin result := Length(S) > 0; for I := 1 to Length(S) do begin result := result and (S[I] in ['0'..'9']); if not result then Break; end; end;
var S : string; begin S := '0123'; if isInteger(S) then showMessage('c''est un chiffre') else showMessage("c''est du texte'); end;