Currency Format In Textbox

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

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
 
Joe said:
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.
 
Me.UnitPriceMaskedTextBox.Text = Format(Val(Me.UnitPriceMaskedTextBox.Text),
"c2")

Tony K
 
Back
Top