| | |
How to format number?
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 26
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Jan 2006
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
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"
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
•
•
Join Date: Mar 2009
Posts: 880
Reputation:
Solved Threads: 163
Or there is the formatnumber function...
Where the "8" after the comma tells the function how many places after the decimal you want.
Good Luck
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
?formatnumber(1/ 2946.33,8) 0.00033941
Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
•
•
Join Date: Mar 2009
Posts: 880
Reputation:
Solved Threads: 163
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
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
If anyone has helped you solve your problem, please mark your thread as solved.
Thanks
Thanks
![]() |
Similar Threads
- Big binary String to a number format (Java)
- Format Number (VB.NET)
- Format of the number (C)
- Currency format in Bash Script (Shell Scripting)
- Format Number in Sql Query (Visual Basic 4 / 5 / 6)
- XSLT to copy a specific number of nodes (XML, XSLT and XPATH)
- Format Number as percentage. (PHP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: start new row in datagrid, msflexgrid
- Next Thread: FormatNumber
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





