format double into string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boni

    #1

    format double into string

    Hi all,
    I am sure there is a simple way to get from double a formated string (but I
    don't know it :).
    D as double=2.687687 649768976
    Resulting string should be 2.688
    Thanks in advance for your help,
    Boni


  • Phil G.

    #2
    Re: format double into string

    Try

    Imports System.Math

    Dim D,E as double
    Dim Result as String

    D=2.68768764976 8976
    E = Round(D,3)
    Result = E.ToString

    HTH, Phil

    "Boni" <oilia@nospam > wrote in message
    news:Oc0UNwzrFH A.1028@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi all,
    > I am sure there is a simple way to get from double a formated string (but
    > I don't know it :).
    > D as double=2.687687 649768976
    > Resulting string should be 2.688
    > Thanks in advance for your help,
    > Boni
    >[/color]


    Comment

    • Scott M.

      #3
      Re: format double into string

      d.ToString.Form at("0.000")


      "Boni" <oilia@nospam > wrote in message
      news:Oc0UNwzrFH A.1028@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Hi all,
      > I am sure there is a simple way to get from double a formated string (but
      > I don't know it :).
      > D as double=2.687687 649768976
      > Resulting string should be 2.688
      > Thanks in advance for your help,
      > Boni
      >[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: format double into string

        "Boni" <oilia@nospam > schrieb:[color=blue]
        > I am sure there is a simple way to get from double a formated string (but
        > I don't know it :).
        > D as double=2.687687 649768976
        > Resulting string should be 2.688[/color]

        \\\
        MsgBox(d.ToStri ng("F3"))
        ///

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • Wayne

          #5
          Re: format double into string

          Dim D As Double = 2.6876876497689 759

          'Resulting string should be 2.688

          Dim S As String

          S = CType(System.Ma th.Round(D, 3), String)

          MessageBox.Show ("S: " & S)

          Wayne



          "Boni" <oilia@nospam > wrote in message
          news:Oc0UNwzrFH A.1028@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Hi all,
          > I am sure there is a simple way to get from double a formated string (but
          > I don't know it :).
          > D as double=2.687687 649768976
          > Resulting string should be 2.688
          > Thanks in advance for your help,
          > Boni
          >[/color]


          Comment

          • Boni

            #6
            Re: format double into string

            Thanks to all,
            this time there is really problem of choice :)
            "Boni" <oilia@nospam > schrieb im Newsbeitrag
            news:Oc0UNwzrFH A.1028@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Hi all,
            > I am sure there is a simple way to get from double a formated string (but
            > I don't know it :).
            > D as double=2.687687 649768976
            > Resulting string should be 2.688
            > Thanks in advance for your help,
            > Boni
            >[/color]


            Comment

            Working...