none
Using Scientific Notation RRS feed

  • Question

  •  How do I make VB display a floating point double in scientific notation format 
    fjww
    Monday, September 29, 2008 11:36 AM

Answers

  • Try this:

    Dim d As Double = 2222.0  
    TextBox1.Text = d.ToString("0.000e0")  
     
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    Monday, September 29, 2008 12:20 PM

All replies

  • Try this:

    Dim d As Double = 2222.0  
    TextBox1.Text = d.ToString("0.000e0")  
     
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    • Marked as answer by FJWW Tuesday, September 30, 2008 3:32 PM
    Monday, September 29, 2008 12:20 PM
  • Converting a Double to a string:
    http://msdn.microsoft.com/en-us/library/shxtf045.aspx

    Formatting numbers:
    http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

    You probably want to look at the exponent (e) format.





    Stephen J Whiteley
    Monday, September 29, 2008 1:14 PM
    Moderator
  • from the documentation

            Dim value As Double = 12345.6789 
            Debug.WriteLine(value.ToString("E")) 
            ' Displays 1.234568E+004 
     
            Debug.WriteLine(value.ToString("E10")) 
            ' Displays 1.2345678900E+004 
     
            Debug.WriteLine(value.ToString("e4")) 
            ' Displays 1.2346e+004 
     

    Monday, September 29, 2008 2:04 PM