|
-
Nov 20th, 2002, 04:45 PM
#1
Thread Starter
Addicted Member
Decimal or Double
Firstly should i use decimal or double for currency?
Secondly how do i get the data type to 2 decimal places. It works fine if the number is 34.56 but when it ends in 0 i.e. 32.10 it knocks off the zero and displays 32.1.
Help please.
Wind and waves resolves all problems.
-
Nov 20th, 2002, 05:09 PM
#2
Sleep mode
MS says :
The Deftype statements are not supported in Visual Basic .NET. Nor is the Currency data type. Instead, use the new Decimal data type, which can handle more digits on both sides of the decimal point, for all money variables and calculations. Decimal is also directly supported by the common language runtime.
logically decimal numbers that end in 0 are left out.
-
Nov 20th, 2002, 06:29 PM
#3
take a look at the Format function. That is, if you want to convert the number to a string representation.... you can add a 0 to the end of it this way
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 20th, 2002, 06:41 PM
#4
Sleep mode
does this happen to everyone here , .Here what I did :
VB Code:
Dim des As Decimal = 1.050
but when I hit enter, the zero at the end was omitted
VB Code:
Dim des As Decimal = 1.05
So no comment
-
Nov 20th, 2002, 06:49 PM
#5
-
Nov 20th, 2002, 07:24 PM
#6
Sleep mode
sure that results in ' results in 11.30 ????
-
Nov 20th, 2002, 08:22 PM
#7
Sleep mode
after you process your decimal variable then convert it to string then add "0" at the end of the variable like so :
VB Code:
Dim des As Decimal = 1.05
des = des.ToString
MsgBox(des & "0")
guess this is the only way to fool MS VS.NET .lol
-
Nov 20th, 2002, 10:56 PM
#8
Originally posted by pirate
after you process your decimal variable then convert it to string then add "0" at the end of the variable like so :
VB Code:
Dim des As Decimal = 1.05
des = des.ToString
MsgBox(des & "0")
guess this is the only way to fool MS VS.NET .lol
aaah did you try what I said?!!
if you want to have the decimal place for 2 digits then you do something like that I said.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 20th, 2002, 11:00 PM
#9
alright my bad. I didnt actually try this in vb until now. The function has changed a bit. You dont have to convert it to string:
Format (myDecimalVar, "#.#0") will do the work, no need to convert the decimal to string
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 21st, 2002, 12:01 AM
#10
Sleep mode
Mr.Polite , you are using String assignment in a way or another ,
look at this :
VB Code:
'this is the Format Function
Format( ByVal Expression As Object, Optional ByVal Style As string = "" ) As String
'we use it this way
Format(mydecimal, “#.##”)
using this function will set and return string value. So there is none difference betwen the two ways
-
Nov 21st, 2002, 04:55 AM
#11
Thread Starter
Addicted Member
Thanks for your help guys but with option strict on format doesn't seem to work.
However you can do this
Dim a As Decimal
a = CType(34.5, Decimal)
Dim value As String = a.ToString("N")
Returns 34.50
Wind and waves resolves all problems.
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
|