Click here to Skip to main content
15,070,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a Textbox in my Form1

I Want to convert Textbox value into Exponent Format
Exa: 0.0009 into Exponent.

In Mouse Leave
double d;
d = Convert.ToDouble(T1.Text);
T1.Text = d.ToString("E");

In Mouse over
C#
double p = double.Parse(T1.Text, System.Globalization.NumberStyles.Any);
T1.Text = p.ToString();

The Result i am getting for 0.0009 is 9.000000E-004
but i want the output as 9E-004.
How to Avoid Zero's From an Exponent Value?

Do let me know if u have any Idea.

Thanks & Regards
Pawan.
Posted
Updated 22-Sep-10 19:22pm
v2

1 solution

You Will have to change your code Slightly and you will have your result.
Take a Look.

MIDL
double d;
d = Convert.ToDouble(T1.Text);
T1.Text = d.ToString("E0");


Here you go.

Vote or Mark as a Answer if it Helps.
   
Comments
Pawan Kiran 23-Sep-10 3:07am
   
Thanks to you. It solves my Problem
Hiren solanki 23-Sep-10 3:12am
   
You welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900