Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2008, 01:43 AM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Default Scientific format to string

I have a string formatted like this '1.0011E+11' in an excel spreadsheet and need it to display as 100110177596.
in excel if I format the cell as numeric with no decimals it works, how can I achieve this through delphi 7


------------------------------------
If you look like your passport photo
you are too ill to travel
Reply With Quote
  #2  
Old 11-06-2008, 02:19 AM
jdg jdg is offline
Senior Member
 
Join Date: Sep 2003
Posts: 1,063
Default RE: Scientific format to string

I understand your original value to be a string and you want the result to be string?

Try this:
Label1.text := FormatFloat('#0',StrToFloat('1.0011e+11'));



jdg.ho

I love this forum. Your generosity is wonderful.
Reply With Quote
  #3  
Old 11-06-2008, 02:40 AM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Default RE: Scientific format to string

Did not work, here is the code I am using
Code:
for c:=2 to rows do
begin
form1.ProgressBar1.Position:=c;
a:=sheet.cells[c,xCol];
sheet.cells[c,xCol]:=FormatFloat('#0',StrToFloat(a));
end;
------------------------------------
If you look like your passport photo
you are too ill to travel
Reply With Quote
  #4  
Old 11-06-2008, 04:28 AM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: Scientific format to string

sheet.cells[c,xCol].NumberFormat := '0';

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
  #5  
Old 11-06-2008, 09:14 AM
chris_w chris_w is offline
Senior Member
 
Join Date: Jan 2004
Posts: 1,397
Default RE: Scientific format to string

[pre]
Following works correctly, you will have to play around with
it to get it to display the wrong answer that you want

[/pre][DELPHI]
ShowMessage( Format('%.0f', [StrToFloat('1.0011E+11')]) );

[/DELPHI][pre]
"There is a theory which states that if ever anybody discovers
exactly what the Universe is for and why it is here, it will
instantly disappear and be replaced by something even more
bizarre and inexplicable. There is another theory which states
that this has already happened."
-- Douglas Adams
[/pre]

Chris
Reply With Quote
  #6  
Old 11-07-2008, 12:49 AM
jdg jdg is offline
Senior Member
 
Join Date: Sep 2003
Posts: 1,063
Default RE: Scientific format to string

It worked.

jdg.ho

I love this forum. Your generosity is wonderful.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:02 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.