Fórum como converter de char para string #297944
30/09/2005
0
algo assim
function TForm1.StrToNum(Str:string):Real; var temp : string; i: integer; v: Real begin FOR i:= 0 TO length(str)do begin temp := copy(str,i,(1)); if temp in [´0..9´] then v:= v+temp; end; result = V end;
se alguem puder me ajudar nessa funcao
Anderson_blumenau
Curtir tópico
+ 0Posts
30/09/2005
Rjun
function TForm1.StrToNum(Str: string): Double; var Aux: string; i: integer; begin Aux := ´´; for i := 1 to Length(Str) do if Str[i] in [´0´..´9´] then Aux := Aux + Str[i]; if Aux <> ´´ then result := StrToFloat(Aux); else result := 0; end;
Gostei + 0
30/09/2005
Anderson_blumenau
mas
se eu colocar um numero tipo R$ 0,25
a funcao me retorna 25, eu gostaria que ela me retornasse um numero real
Gostei + 0
30/09/2005
Rjun
function TForm1.StrToNum(Str: string): Double; var Aux: string; i: integer; begin Aux := ´´; for i := 1 to Length(Str) do if Str[i] in [´0´..´9´, ´,´] then Aux := Aux + Str[i]; try result := StrToFloat(Aux); except result := 0; end; end;
Gostei + 0
30/09/2005
Anderson_blumenau
estupidez a minha nao ter visto isso
as vezes o cara fica meio cego e nao ve o mais simples
valeu cara
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)