locked
Displaying scientific notation in VB Express 2008 RRS feed

  • Question

  • Hello!  I've written a small program that does some calculations and I want to display some of the results in scientific notation. For example, I want to display 0.005 as 5.0E-3. Is there a way to do this? If so, please give some sample code as I am VERY new to VB.

    Thanks!
    Jeff
    Monday, September 28, 2009 5:08 PM

Answers

  • Try something like
    Dim num as decimal=0.005D
    Dim SN as string=num.ToString("E1")

    Note: E or e is the format specifier for scientific notation
    and append the number of decimal places with E such as ("E1") 1 decimal places


    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    • Edited by kaymaf Monday, September 28, 2009 5:21 PM incomplete
    • Marked as answer by Jefferal Monday, September 28, 2009 7:08 PM
    Monday, September 28, 2009 5:17 PM

All replies

  • Try something like
    Dim num as decimal=0.005D
    Dim SN as string=num.ToString("E1")

    Note: E or e is the format specifier for scientific notation
    and append the number of decimal places with E such as ("E1") 1 decimal places


    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    • Edited by kaymaf Monday, September 28, 2009 5:21 PM incomplete
    • Marked as answer by Jefferal Monday, September 28, 2009 7:08 PM
    Monday, September 28, 2009 5:17 PM
  • kaymaf:

    That did the trick wonderfully!!  THANKS! 

    Jeff
    Monday, September 28, 2009 7:10 PM