anonymous,
Cita:
Empezado por anonymous
...Ingresando el usuario un Nombre y Apellido (DIEGO ARMANDO MARADONA)...Cada letra tiene su valor...Sumar los números asignados a una palabra...
|
Revisa este código:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
public
end;
TAction = (Esencia = 1, Imagen = 2, Destino = 3, Sendero = 4);
var
Form1: TForm1;
ABC : Array['a'..'z'] of Byte = (1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8);
implementation
{$R *.dfm}
function Numerology(Value : String; Action : TAction) : Byte;
var
SL : TStringList;
i, j, k : Integer;
AuxValue, AuxNum : String;
NumValue : Integer;
L : Char;
begin
SL := TStringList.Create;
ExtractStrings([' ','/','-'], [], PChar(Value), SL);
Result := 0;
for i := 0 to SL.Count - 1 do
begin
AuxValue := LowerCase(SL[i]);
NumValue := 0;
for j := 1 to Length(AuxValue) do
begin
L := AuxValue[j];
if (Action = Esencia) and (L in ['a','e','i','o','u']) then
NumValue := NumValue + ABC[L];
if (Action = Imagen) and not (L in ['a','e','i','o','u']) then
NumValue := NumValue + ABC[L];
if (Action = Destino) then
NumValue := NumValue + ABC[L];
if (Action = Sendero) then
begin
if AuxValue[j] in ['0','1','2','3','4','5','6','7','8','9'] then
NumValue := NumValue + StrToInt(AuxValue[j]);
if NumValue > 9 then
repeat
AuxNum := IntToStr(NumValue);
NumValue := 0;
for k := 1 to Length(AuxNum) do
NumValue := NumValue + StrToInt(AuxNum[k]);
until NumValue < 10
end;
end;
Result := Result + NumValue;
end;
SL.Free;
if Result in [11,22] then
Exit;
if Result > 9 Then
repeat
AuxValue := IntToStr(Result);
Result := 0;
for j := 1 to Length(AuxValue) do
Result := Result + StrToInt(AuxValue[j]);
if Result in [11,22] then
Break;
until (Result < 10);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Name : String;
DateBirth : String;
begin
Name := 'Diego Armando Maradona';
DateBirth := '30/10/1960';
ListBox1.Clear;
ListBox1.Items.Add(Format('Nombre = %s',[Name]));
ListBox1.Items.Add(Format('Fecha Natal = %s',[DateBirth]));
ListBox1.Items.Add(Format('Esencia = %d',[Numerology(Name,Esencia)]));
ListBox1.Items.Add(Format('Imagen = %d',[Numerology(Name,Imagen)]));
ListBox1.Items.Add(Format('Destino = %d',[Numerology(Name,Destino)]));
ListBox1.Items.Add(Format('Sendero = %d',[Numerology(DateBirth,Sendero)]));
end;
end.
El código anterior en Delphi 7 sobre Windows 7 Profesional x32,
Realiza cálculos numerológicos basados en la información obtenida de las imágenes de los Msg # 1 y #6, como se muestra en la siguiente imagen:
Nota: El código propuesto tiene como único objetivo,
servir de guía a los requerimientos planteados en los
Msg #1 y
Msg #6.
Espero sea útil ![Smilie](http://www.clubdelphi.com/foros/images/smilies/smile.gif)
Nelson.