Format Textbox with Floating Decimal Point

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy

    #1

    Format Textbox with Floating Decimal Point

    I'm sure that this has been posted before, but I can't find it.
    Please accept my apologies for any redundancy.

    I have a textbox that contains numbers pulled from a SQL database
    column. These the datatype in the db is set to "decimal(18 , 4)", so
    the number is stored with 4 decimal places, although they could all be
    zeros. When I pull these numbers into the textbox, I want to display
    only the significant digits (i.e. drop any trailing zeros). For
    example, if the db contains a number of "5.1200", I want to display
    "5.12". If the db showed "5.1234", I want to display "5.1234". If it
    contains "5.0000", I want to display "5".

    I can change the datatype of the SQL table if that will help.

    Thanks,
    Randy

  • =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=

    #2
    RE: Format Textbox with Floating Decimal Point

    Randy,

    I have not tried this, but pretty sure it should work:
    myTextBox.Text = CType(myDatabas eField, Single).ToStrin g()

    "Randy" wrote:
    I'm sure that this has been posted before, but I can't find it.
    Please accept my apologies for any redundancy.
    >
    I have a textbox that contains numbers pulled from a SQL database
    column. These the datatype in the db is set to "decimal(18 , 4)", so
    the number is stored with 4 decimal places, although they could all be
    zeros. When I pull these numbers into the textbox, I want to display
    only the significant digits (i.e. drop any trailing zeros). For
    example, if the db contains a number of "5.1200", I want to display
    "5.12". If the db showed "5.1234", I want to display "5.1234". If it
    contains "5.0000", I want to display "5".
    >
    I can change the datatype of the SQL table if that will help.
    >
    Thanks,
    Randy
    >
    >

    Comment

    • Randy

      #3
      Re: Format Textbox with Floating Decimal Point

      That works. Thanks a lot, Sergey.

      Randy

      Comment

      Working...