CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 1999
    Location
    Québec (Canada)
    Posts
    210

    Number to string

    Hi,
    I would like to put 2.222545E-3 in string var.

    I want "0.00222545" but I receive "2.222545E-3"

    Somebody can help me?

    Thanks
    Redg


  2. #2
    Join Date
    Jan 2001
    Posts
    165

    Re: Number to string


    Dim dNum as Double
    Dim sNum as string

    sNum = "2.222545E-3"
    dNum = sNum
    sNum = dNum

    MsgBox dNum



    There should be a way to do this with the Format function but I could not get it to work with this sort of string constant. Here I just let VB do the conversion to a double and then back to a string to get the output that you requested.

    -K


  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Number to string


    private Sub Command1_Click()
    Dim sng as Single
    sng = 0.00222545
    MsgBox Format(sng, "0.####################")
    End Sub




    John G

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

Featured