Decimal dropped when value is zero , windows , text files Austin, United States
  • 11 years ago

    In my app, I am converting text to doubles. It continues to drop the trailing zeros and the decimal on numbers.

    .5 works fine 22.3125 works fine 0.0 does not work. it drops the "." and returns a blank value, or no value 1.0 drops the "." and the trailing zero

    I have included the sample code I have been using to test different theories. I don't think using text boxes is the problem because I am having the same exact issues in my real code.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim MyNumber As Double
        MyNumber = TextBox1.Text
        TextBox2.Text = Format(MyNumber, "#.####")
    End Sub

    This will not work for me. Any help, thanks in advance.

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match” - Bill Bryson