Search code examples
vb.netdoublenumberspresentation

vb.net, full number presentation with small double number


if I have a small double in vb.net like this:

dim x as double = 0.00000003

a conversion to a string would produce a E-presentation (3E-7). in debugging the value it will be shown as full number (0.00000003).

how can I get the full number in a string?


Solution

  • With the .ToString() method and a format string:

    Dim y As String = x.ToString("F7")
    

    Standard Format Strings
    Custom Format Strings

    Note that this still requires you to choose a specific format. If you want it to automatically match the string literal you used in your code, then you have a problem because that information is not preserved.