como converter de char para string
eu estava querendo fazer uma funcao pra retornar soh os numeros de uma string
algo assim
se alguem puder me ajudar nessa funcao
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
Curtidas 0
Respostas
Rjun
30/09/2005
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
Anderson_blumenau
30/09/2005
valeu pena ajuda amigo, e foi bem rapida
mas
se eu colocar um numero tipo R$ 0,25
a funcao me retorna 25, eu gostaria que ela me retornasse um numero real
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
Rjun
30/09/2005
Então altere a linha do if.
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
Anderson_blumenau
30/09/2005
claro
estupidez a minha nao ter visto isso
as vezes o cara fica meio cego e nao ve o mais simples
valeu cara
estupidez a minha nao ter visto isso
as vezes o cara fica meio cego e nao ve o mais simples
valeu cara
GOSTEI 0