Hi guys,

i am a problem when i doing my coding about format a number

for normal number with 4 digit , i have idea which is
e.g: Dim a As double
a = 1/ 2946.33 ' its return is 0.00033940529

If i use format number function with 4digits, the answer is "0.0003"
but i need to the format number with 4 digit which is not included 0
: "0.0003394"

Can i anyone tell me how to do?

e.g: Dim a As double
a = 1/ 2946.33 ' its return is 0.00033940529

If i use format number function with 4digits, the answer is "0.0003"
but i need to the format number with 4 digit which is not included 0
: "0.0003394"

This is really a job for Scientific Notation
As you point out Format(a,"0.0000") or Format(a,"0.####")
means that you lose digits you want to keep.

If you want, you can use:
Format(a,"0.########")
Then, you will always get 8 digits to the right of the decimal point.
But -- are your measurements really that precise and are they really that accurate? On part in a 100 million is very high accuracy/

A better way (in my opinion) would be: Format(a,"0.####E-##")
This would display as 3.3941E-4

--Vorpal

Or there is the formatnumber function...

?formatnumber(1/ 2946.33,8)
0.00033941

Where the "8" after the comma tells the function how many places after the decimal you want.

Good Luck

how about this sitsuation:

=FormatNumber(Sum(Fields!TotalProductPrice.Value),2)
it returns for exsample following: 1.2345. I need to replace . with ,
how can I do it

The replace function.

However, let me remind you that you should have started your own thread and if you wanted to reference this thread you could have copied the url and posted it with your post with words like, in reference to...

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.