Format string question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kevininstructor@state.or.us

    Format string question

    The following was copied from a web site for learning formatting.
    Dim myInt As Integer = 100
    Dim FormatPrice As String = String.Format(" Price = |{0,10:c }|", myInt)
    Console.WriteLi ne(FormatPrice)
    The result shown is no number but the character c as in the format string.
    Is the format not valid in this context?

    Thanks for your assistance,
    Kevin





  • Robby

    #2
    Re: Format string question

    The format string should be "Price = |{0:c10}|" . This will give you:

    Price = |$100.000000000 0|

    in the console window if you are using the English (United States) as your
    language . For more information on Standard Numeric Format Strings check
    out




    --Robby



    "kevininstructo r@state.or.us" <Kevin.S.Gallag her@state.or.us > wrote in
    message news:ek1lb0mzEH A.3028@TK2MSFTN GP10.phx.gbl...[color=blue]
    > The following was copied from a web site for learning formatting.
    > Dim myInt As Integer = 100
    > Dim FormatPrice As String = String.Format(" Price = |{0,10:c }|", myInt)
    > Console.WriteLi ne(FormatPrice)
    > The result shown is no number but the character c as in the format string.
    > Is the format not valid in this context?
    >
    > Thanks for your assistance,
    > Kevin
    >
    >
    >
    >
    >[/color]


    Comment

    Working...