Board index » cppbuilder » Re: ThousandSeparator

Re: ThousandSeparator


2004-02-09 12:55:13 AM
cppbuilder41
Hello Guba,
How can I convert AnsiString with ThousandSeparator to Float
for example (AnsiString 100.000,00 ->Float 100.000,00)
Here is a short example of removing your comma and converting.
If you want, you can use the same example and change the period to a command
and comma to a period.
int a;
AnsiString Buf1;
Buf1=Form1->Edit1->Text;
while(a=Buf1.Pos(','))Buf1=Buf1.SubString(1,a-1)+Buf1.SubString(a+1,Buf1.Len
gth()-a);
Form1->Edit2->Text=Buf1;
Dwayne
 
 

Re:Re: ThousandSeparator

I use bcb5, win98,
How can I convert AnsiString with ThousandSeparator to Float
for example (AnsiString 100.000,00 ->Float 100.000,00)
 

Re:Re: ThousandSeparator

I use bcb5, win98,
How can I convert AnsiString with ThousandSeparator to Float
for example (AnsiString 100.000,00 ->Float 100.000,00)
 

{smallsort}

Re:Re: ThousandSeparator

Hello Guba,
There is no way to do that. As long as I have already sent you a copy of the text of StrToFloat help, no other signal except the decimal point ( or comma) may be present. So you should remove all thousand separator of the string before try to convert it.
If you are getting the currency value from a database table you can just use the AsFloat property instead of AsString, and the BDE will the job for you.
HTH
Jayme.
"Guba" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
I use bcb5, win98,
How can I convert AnsiString with ThousandSeparator to Float
for example (AnsiString 100.000,00 ->Float 100.000,00)


 

Re:Re: ThousandSeparator

Hello Guba,
You migth use the code bellow to delete de invalid entries :
System::AnsiString Source = 1.000.000,54 // ThousandSeparator = '.' (dot)
for( int i=1; i< Source.Length(); ++i){
if(Source[i] == ThousandSeparator) Source.Delete(i,1);
}
HTH
Jayme.
"Dwayne" < XXXX@XXXXX.COM >wrote in message news:40279def$ XXXX@XXXXX.COM ...
Quote
Hello Guba,

How can I convert AnsiString with ThousandSeparator to Float
for example (AnsiString 100.000,00 ->Float 100.000,00)

Here is a short example of removing your comma and converting.
If you want, you can use the same example and change the period to a command
and comma to a period.


int a;
AnsiString Buf1;
Buf1=Form1->Edit1->Text;

while(a=Buf1.Pos(','))Buf1=Buf1.SubString(1,a-1)+Buf1.SubString(a+1,Buf1.Len
gth()-a);
Form1->Edit2->Text=Buf1;

Dwayne