var iTotal : integer; iNoChar : integer; sValue : string; begin iTotal := 0; sValue := 'nico'; sValue := UpperCase(sValue); for iNoChar := 1 to Length(sValue) do iTotal := iTotal + word(sValue[iNoChar]) - (word(Char('A')) - 1); ShowMessage(IntToStr(iTotal));
function CompteValeurMot(Mot: String): Integer; var i: Integer; Val: Integer; begin Result := 0; Mot := AnsiLowerCase(Mot); for i := 1 to Length(Mot) do begin if (Mot[i] in ['0'..'9', ' ', '-']) {1} then Val := 0 else if Mot[i] in ['a', 'à', 'â', 'ä'] then Val := 1 else if Mot[i] in ['e', 'é', 'è', 'ê', 'ë'] then Val := 5 else if Mot[i] in ['i', 'î', 'ï'] then Val := 9 else if Mot[i] in ['o', 'ô', 'ö'] then Val := 15 else if Mot[i] in ['u', 'ù', 'û', 'ü'] then Val := 21 else Val := Ord(Mot[i]) - 96; Result := Result + Val; end; { 1 On peut énumérer d'autres caractères comme ';', ':' etc... } end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionfunction CompteValeurMot(Mot: String): Integer; var i: Integer; Val: Integer; begin Result := 0; Mot := AnsiLowerCase(Mot); for i := 1 to Length(Mot) do begin if Mot[i] in ['a', 'à', 'â', 'ä'] then Val := 1 else if Mot[i] in ['e', 'é', 'è', 'ê', 'ë'] then Val := 5 else if Mot[i] in ['i', 'î', 'ï'] then Val := 9 else if Mot[i] in ['o', 'ô', 'ö'] then Val := 15 else if Mot[i] in ['u', 'ù', 'û', 'ü'] then Val := 21 else if Mot[i] in ['c', 'ç'] then Val := 3 else if Mot[i] in ['a'..'z'] then Val := Ord(Mot[i]) - 96 else Val := 0; Result := Result + Val; end; end;