pegar valor dos arrays
30/11/2005
0
procedure TForm1.Button1Click(Sender: TObject);
const
numeros: array[0..9] of string = (´00´,´01´,´02´,´03´,´04´,´05´,´06´,´07´,´08´,´09´);
letras : array[´A´..´Z´] of string = (´10´,´11´,´12´,´13´,´14´,´15´,´16´,´17´,´18´,´19´,´20´,´21´,´22´,´23´,
´24´,´25´,´26´,´27´,´28´,´29´,´30´,´31´,´32´,´33´,´34´,´35´) ;
var EMPRESA,VALOR,teste: string;
begin
EMPRESA := ´OE´;
teste := COPY(EMPRESA,1,1);
VALOR := letras[teste];
teste := COPY(EMPRESA,2,1);
VALOR := Valor+letras[´E´];
showmessage(valor);
end;
Eric.miranda
Posts
30/11/2005
Massuda
procedure TForm1.Button1Click(Sender: TObject); const numeros: array[0..9] of string = (´00´,´01´,´02´,´03´,´04´,´05´,´06´,´07´,´08´,´09´); letras : array[´A´..´Z´] of string = (´10´,´11´,´12´,´13´,´14´,´15´,´16´,´17´,´18´,´19´,´20´,´21´,´22´,´23´, ´24´,´25´,´26´,´27´,´28´,´29´,´30´,´31´,´32´,´33´,´34´,´35´) ; var EMPRESA,VALOR: string; teste: Char; begin EMPRESA := ´OE´; teste := EMPRESA[1]; VALOR := letras[teste]; teste := EMPRESA[2]; VALOR := Valor+letras[teste]; showmessage(valor); (* ou, dum modo mais generico... Valor := ´´; for I := 1 to Length(Empresa) do begin Valor := Valor + Letras[Empresa[I]]; end; *) end;
30/11/2005
Eric.miranda
só mais uma coisa se vc puder me dizer se tem como..
teria como juntar esses dois arrays,
pq tenho uma coisa do tipo.
OEA100001
e tenho que ficar verificando e conventendo cada caracter em seu valor correspondente no array e ir somando
ex O = 24 E= 14 A=10 etc..
24+14+10
valeu
30/11/2005
Eric.miranda
procedure TForm1.Button2Click(Sender: TObject);
const
numeros: array[0..9] of string = (´00´,´01´,´02´,´03´,´04´,´05´,´06´,´07´,´08´,´09´);
letras : array[´A´..´Z´] of string = (´10´,´11´,´12´,´13´,´14´,´15´,´16´,´17´,´18´,´19´,´20´,´21´,´22´,´23´,
´24´,´25´,´26´,´27´,´28´,´29´,´30´,´31´,´32´,´33´,´34´,´35´) ;
var EMPRESA,VALOR: string;
teste: Char;
i: integer;
begin
EMPRESA := ´EPA1123456´;
for i:= 1 to 10 do
begin
teste := EMPRESA;
if (teste in [´A´..´Z´]) then
begin
VALOR := valor+letras[Empresa];
end
else
begin
VALOR := valor+numeros[Empresa];//dá erro aqui!!!!!
end;
end;
showmessage(valor);
end;
vejam se vcs podem me ajudar em mais essa..
valeu pessoal
30/11/2005
Massuda
VALOR := valor+numeros[Ord(Empresa)];
30/11/2005
Massuda
... for i:= 1 to Length(Empresa) do begin teste := EMPRESA[I]; if (teste in [´A´..´Z´]) then begin VALOR := valor+letras[teste]; end else begin VALOR := valor+numeros[Ord(teste)]; end; end; ...
Clique aqui para fazer login e interagir na Comunidade :)