|
-
Mar 2nd, 2003, 04:41 PM
#1
Thread Starter
Hyperactive Member
Working With Numbers... {Resolved}
Ok what I am trying to do is show 2 decimal places...
For Example:
1.20 not 1.2 --- Below is my Code... can anyone help me here?
Dim Amount As Double
Amount = 1.20
'Display Amount
lblAmount.Text = "$" + Amount.ToString()
Last edited by Anjari; Mar 2nd, 2003 at 07:56 PM.
-
Mar 2nd, 2003, 07:25 PM
#2
Lively Member
You just have to format it to what you want, try changing the last line to this and see if it works.
Code:
'Display Amount
lblAmount.Text = Amount.ToString("$ ##.00")
-
Mar 2nd, 2003, 07:56 PM
#3
Thread Starter
Hyperactive Member
Thanks
Worked Great Thanks!
Anjari
-
Mar 7th, 2003, 10:27 PM
#4
Member
What If Already A String ? (Formatting)
Code:
Dim Amount As Integer = "12345"
Label1.Text = "$" & Amount.ToString("##,###")
This will obviously work and display: $12,345
But What if the Amount varible is already as String, example:
Code:
Dim Amount As String = "12345"
Label1.Text = "$" & Amount.ToString("##,###")
The above will now give an error so how would you format the varible that's already a string the vb.net way?
-
Mar 8th, 2003, 04:01 PM
#5
Junior Member
Hello JustAProg,
Well, here is a workaround of sorts.....
VB Code:
Dim Amount As String = "12345"
Amount = "$" & Format(Convert.ToInt64(Amount), "###,###,###.00")
MsgBox(Amount)
Last edited by RvA; Mar 8th, 2003 at 04:05 PM.
Best,
Roger
VB6.0 SR5 & VB.Net Pro
-----------------------------------------------
Do or do not, there is no try!
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
|