943,703 Members | Top Members by Rank

Ad:
May 27th, 2009
0

How to format number?

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
nokomoli is offline Offline
26 posts
since Nov 2007
May 27th, 2009
0

Re: How to format number?

Click to Expand / Collapse  Quote originally posted by nokomoli ...
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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Vorpal is offline Offline
5 posts
since Jan 2006
May 27th, 2009
0

Re: How to format number?

Or there is the formatnumber function...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ?formatnumber(1/ 2946.33,8)
  2. 0.00033941
Where the "8" after the comma tells the function how many places after the decimal you want.

Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Jun 2nd, 2009
0

Re: How to format number?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jouni79 is offline Offline
2 posts
since Jun 2009
Jun 2nd, 2009
0

Re: How to format number?

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: start new row in datagrid, msflexgrid
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: FormatNumber





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC