-
Jan 12th, 2019, 06:13 AM
#1
Thread Starter
Junior Member
VB Satoshi convert help
6.78845934253293e-05 = 0.00006788
6.78845934253293e-06 = 0.00000678
5.57578546610181e-07 = 0.00000055
how do I make this change
do you have a code that provides
-
Jan 12th, 2019, 06:39 AM
#2
Re: VB Satoshi convert help
Originally Posted by sorgu
6.78845934253293e-05 = 0.00006788
6.78845934253293e-06 = 0.00000678
5.57578546610181e-07 = 0.00000055
how do I make this change
do you have a code that provides
I found two ways:
1. Store the numbers using the Decimal datatype or convert them to the Decimal datatype before displaying them.
2. Put your numbers in between braces and add ".ToString("F20") where the "20" part means use 20 zeros.
Examples:
Code:
Console.WriteLine(CDec(0.0000678845934253293))
Console.WriteLine((0.0000678845934253293).ToString("F30"))
-
Jan 12th, 2019, 07:00 AM
#3
Re: VB Satoshi convert help
Funny I thought this was the VB6 and earlier forum.
Code:
Option Explicit
Private Sub Form_Load()
Dim N As Double
N = 6.78845934253293E-05
N = Format(N, "0.00000000")
MsgBox N
End Sub
-
Jan 12th, 2019, 07:01 AM
#4
Re: VB Satoshi convert help
-
Jan 12th, 2019, 07:34 AM
#5
Re: VB Satoshi convert help
Originally Posted by Steve Grant
Funny I thought this was the VB6 and earlier forum.
Code:
Option Explicit
Private Sub Form_Load()
Dim N As Double
N = 6.78845934253293E-05
N = Format(N, "0.00000000")
MsgBox N
End Sub
Oops, my mistake. My first example of converting to the Decimal data type still holds though. It works in vb6 too. (Except for writing to the console.)
Last edited by Peter Swinkels; Jan 12th, 2019 at 07:37 AM.
Reason: Added some info.
-
Jan 13th, 2019, 05:57 AM
#6
Re: VB Satoshi convert help
@Peter, actually no it doesn't. Try this;
Private Sub Form_Load()
Dim N As Double
N = 6.78845934253293E-05
'N = Format(N, "0.00000000")
N = CDec(N)
MsgBox N
End Sub
-
Jan 13th, 2019, 05:58 AM
#7
Re: VB Satoshi convert help
@Peter, actually no it doesn't. Try this;
Code:
Private Sub Form_Load()
Dim N As Double
N = 6.78845934253293E-05
'N = Format(N, "0.00000000")
N = CDec(N)
MsgBox N
End Sub
-
Jan 13th, 2019, 07:57 AM
#8
Re: VB Satoshi convert help
Originally Posted by Steve Grant
@Peter, actually no it doesn't. Try this;
Code:
Private Sub Form_Load()
Dim N As Double
N = 6.78845934253293E-05
'N = Format(N, "0.00000000")
N = CDec(N)
MsgBox N
End Sub
Hi Steve,
Thanks for your reply. There is a difference between the example I gave and yours: You are converting a variable declared as a Double to a Decimal and then assigning the converted value back to that same variable causing it to be implicitly converted back to a Double. Either use "MsgBox CDec(N)") or use a numeric literal instead of a variable declared as a Double. As I did.
Last edited by Peter Swinkels; Jan 13th, 2019 at 08:35 AM.
Reason: typo
-
Jan 13th, 2019, 08:30 AM
#9
Re: VB Satoshi convert help
Hi Peter, how right you are. Many thanks.
-
Jan 13th, 2019, 08:34 AM
#10
Re: VB Satoshi convert help
Originally Posted by Steve Grant
Hi Peter, how right you are. Many thanks.
You're welcome. :-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|