Currency Format In Textbox

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

    Currency Format In Textbox

    Hi,

    I am storing a field in SQL Server with a datatype of money.
    When I pull that field back into my VB.NET client program, I put it
    into a typed dataset with a field type of System.Decimal.

    When it displays in the textbox that I have tied to the
    dataset, it appears as 4000.0000 but I want it to appear as $4,000.00

    How can I achieve this format in my textbox? Remember that
    the underlying field is a Money datatype and not a string datatype.


    J
  • Harry

    #2
    Re: Currency Format In Textbox

    "Joe" <delphi561@cox. netwrote in message
    news:c8d7b796-f4b8-40cd-a430-298432531bf3@p6 9g2000hsa.googl egroups.com...
    Hi,
    >
    I am storing a field in SQL Server with a datatype of money.
    When I pull that field back into my VB.NET client program, I put it
    into a typed dataset with a field type of System.Decimal.
    >
    When it displays in the textbox that I have tied to the
    dataset, it appears as 4000.0000 but I want it to appear as $4,000.00
    >
    How can I achieve this format in my textbox? Remember that
    the underlying field is a Money datatype and not a string datatype.
    >
    >
    J
    Couple of options I can think of:
    1. Use data binding. This allows for optional formatting of the text box
    2. Use the CONVERT function in Sql eg SELECT CONVERT(MyMoney , varchar) AS
    MyMoney

    If you use the second option, you will have to lookup the CONVERT function
    in Sql. The above example returns two decimal places by default. There is a
    third parameter for the CONVERT function that alters output.


    Comment

    • Cor Ligthert[MVP]

      #3
      Re: Currency Format In Textbox

      Joe,

      Have you ever looked at the masked textbox.



      Cor

      "Joe" <delphi561@cox. netschreef in bericht
      news:c8d7b796-f4b8-40cd-a430-298432531bf3@p6 9g2000hsa.googl egroups.com...
      Hi,
      >
      I am storing a field in SQL Server with a datatype of money.
      When I pull that field back into my VB.NET client program, I put it
      into a typed dataset with a field type of System.Decimal.
      >
      When it displays in the textbox that I have tied to the
      dataset, it appears as 4000.0000 but I want it to appear as $4,000.00
      >
      How can I achieve this format in my textbox? Remember that
      the underlying field is a Money datatype and not a string datatype.
      >
      >
      J

      Comment

      • Tony K

        #4
        Re: Currency Format In Textbox

        Me.UnitPriceMas kedTextBox.Text = Format(Val(Me.U nitPriceMaskedT extBox.Text),
        "c2")

        Tony K

        "Cor Ligthert[MVP]" <notmyfirstname @planet.nlwrote in message
        news:7AC51D73-2FB8-4425-93CB-FB176E0D7A81@mi crosoft.com...
        Joe,
        >
        Have you ever looked at the masked textbox.
        >

        >
        Cor
        >
        "Joe" <delphi561@cox. netschreef in bericht
        news:c8d7b796-f4b8-40cd-a430-298432531bf3@p6 9g2000hsa.googl egroups.com...
        >Hi,
        >>
        > I am storing a field in SQL Server with a datatype of money.
        >When I pull that field back into my VB.NET client program, I put it
        >into a typed dataset with a field type of System.Decimal.
        >>
        > When it displays in the textbox that I have tied to the
        >dataset, it appears as 4000.0000 but I want it to appear as $4,000.00
        >>
        > How can I achieve this format in my textbox? Remember that
        >the underlying field is a Money datatype and not a string datatype.
        >>
        >>
        >J
        >

        Comment

        Working...