Results 1 to 5 of 5

Thread: Working With Numbers... {Resolved}

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    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.

  2. #2
    Lively Member
    Join Date
    Jan 2002
    Posts
    105
    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")

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    Thanks

    Worked Great Thanks!

    Anjari

  4. #4
    Member
    Join Date
    Sep 2002
    Posts
    53

    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?

  5. #5
    Junior Member RvA's Avatar
    Join Date
    Oct 2002
    Location
    USA
    Posts
    19
    Hello JustAProg,

    Well, here is a workaround of sorts.....

    VB Code:
    1. Dim Amount As String = "12345"
    2.  
    3. Amount = "$" & Format(Convert.ToInt64(Amount), "###,###,###.00")
    4. 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
  •  



Click Here to Expand Forum to Full Width